fixes check for eof