Testing stream.good() or !stream.eof() reads last line twice

Possible Duplicate: Why is iostream::eof inside a loop condition considered wrong? I have the following piece of code: ifstream f("x.txt"); string line; while (f.good()) { getline(f, line);...