handle EOF on input stream