write an output file with cleaned up text