write statistics to file