New code to save output to file.