fixed bug with end of file