Better EOF handling