Fix a missing end statement

There was a missing end statement after a loop.