handle EOF cases