in reply to Making two loops into one

It looks like you can just do everything you do in the second loop, within the if-block of the first loop.

Caution: Contents may have been coded under pressure.