Because you are using a while loop and it is going to print an answer for each iteration, this is how you have designed your code, if this is not what you want, check your logic again.
The word2 column (the one you are subseting with answer[1:5, 1]) is a factor variable and levels are the unique values in that variable.
Sorry but answering that would be the same as doing your work for you and that would go against our homework policy