Replace one-time do-while loop and subsequent break check with simple if.