I would invert this diff. Run the algorithm as:

  diffAlgorithm.diff(textComparator, currentText, nextText)

Then we are looking at the diff "normally", rather than in reverse. Lines that were added by nextText (aka the prior loop iteration) are shown on the "B" side of the difference as additions, the same way you would see that if you ran `git log -p`. This makes it easier to reason about how the difference is being used during mergeLines().