updated print_stat to flush to stdout