added function to write output to file: testing