Added EOF handling