I want to get into this situation

how coul I archive this?
I want to get into this situation

how coul I archive this?
in this specific case, but not in the generic case
i and start of line i+1, connect end of line i+1 with end of line i+2, loop over all expect the two last lines