Using paste command:
paste -d, -s file
aaabbbcccddd
cat file | xargs
aaa bbb ccc ddd
cat file | xargs | sed -e 's/ /,/g'
aaa,bbb,ccc,ddd
There are many ways it can be achieved. The tool you use mostly depends on your own preference or experience.
Using tr command:
tr '\n' ',' < somefile
Using awk:
awk -F'\n' '{if(NR == 1) {printf $0} else {printf ","$0}}' somefile