Not sure the new `concat()` function is needed; instead, using `MCStringAppendFormat(t_output, "%a,", <string to append>)` in each `if` and in the end, removing the last character if `!first` would be simpler in my opinion. Not a compulsory change though.
More important, you forgot to release `t_output`.