fixed crash on EOF