Fixed leave_file in iterate_with_stats