in reply to How to loop over groups

init and finish sections are repeated! In the real code, these sections are both a dozen lines, and they constantly get out-of-sync: a major source of bugs.

This calls for a function. It'll also make it easier to track your logic. :-)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.