consume eof properly