When istream::getline reaches the EOF, it sets the failbit. Then it must be cleared, so that a successful read does not return a failed stream.