Add end of file check