Handle EOF properly.