fixed eof check