writing results to file