foreach line in file1... { loop through lines in file2... { ...many comparisons... decide which one is next } }