Well, you can replace the "\n" with a comma, but it looks like you want a newline every 2nd item, so you'd need a ctr (or a flag) to tell you when to use a newline or a comma.
Thanks for reply. Actually if u look at the code, sql query is
in the loop, query returns more than one item for every element, I need commas between items for one element and then new line for different elements. i dont know it is possible or not