add method to write cleaned output file. refactor initialize to take a filename.