Should this not happen outside of the loop, and the loop then moved into the else block on this condition?