Handle EOF error gracefully