print_stat should flush to stdout