working except eof check
things work but eof check not