added checking for eof