If you want to do it manually, just prepend the comma before any tag but the first one. Use a control variable to detect the first tag.
You can buffer your output (the tags). Let's say you put them in an array.