added some fflush() calls to make sure the statistics lines are