Changed main to output a file in addition to print