started function to save results to file