I like using paste to convert a list of lines into a single line, comma-delimited list...
Contrived example, for brevity:
awk 'BEGIN { while (i < 10) print i++ }' | paste -sd, -
or maybe: ls *txt | paste -sd, -