Merge two for loops of different file types to one