Fix templating loops

I was silly, there was a return statement in this loop!

Fixes #73152.

Auditors: benkomalo