Using file end testing instead of eof