close infile after reading, added file/edit output modes and one example