Hoist this block out of the loop. Its executed exactly once. There is no reason to be doing the if lastText != null test on every iteration of the loop, or having to jump over this block of code before it gets executed.

Sure, a compiler could do this for you. If it was really smart. But its still damn confusing for a human to read because now I'm looking for "How does Kevin set lastText = null in the body of the loop to make this block reachable after the first iteration?" and the answer is... he doesn't.