it's better to use:
while( !in.eof() && in.good() )