fixed check eof Segmentation fault