fixed EOF bug