writing aggregated data to file