Fixed possible bug with EOF