write output into file