Fixed EOF bug