handle EOF