Read the FAQ.
The eof is only set when trying to read some more fails. If it fails, in will not modify what it is trying to input to. It will not be set when you read the last line because that last read is successful. Hence you'll get a dummy "reread" of the last line.
The solution proposed in this thread (and FAQ) exits the loop as soon as in fails to input anything.