By changing the number “3” to something else you can make combine a different number of lines into one. Here are two examples:

awk 'ORS=NR%3?",":"\n"' 

awk '{if (NR%3) {ORS="";print " "$0} else {ORS="\n";print " "$0}}'