Correct month skipping problem when iterating through files