working except for eof