Write output to files