function to write output results and info