fix eof check in loader