Write output to a file rather than print