fixed error with EOF during buffer read