in reply to Check for next array element.

Yet another suggestion: go through the loop and tell ever item (including the last one) that it's not the last. Then after the main loop, change the value for the last item. It's not as direct as some of the other suggestions, but if there's a lot of other stuff in the loop, it might be the simplest.