in reply to looping efficiency

/me screams into the void: "The overhead of generating the number strings is completely irrelevant".

This is one of the plethora of guises of premature optimisation. Don't do that! Write your code so that it is clear and easy to maintain - in this case probably using sprintf. If benchmarking demonstrates that this piece of code is a significant bottleneck then it is time to think about generating something quicker. If there is any other I/O going on in the code then it is pretty much guaranteed that a simple sprintf solution is not going to contribute enough overhead to be an issue.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond