How to get code-snippet to only 'loop' once?

You need to post the complete program so we can see the context.

A common way to ensure a piece of code only runs once is to have a variable that counts how many times it runs.

...R