Write output to file