Move sync line pointers code to the end of the loop, it is simpler that way.