then this command will do
sed 's/ /,/g' filename
or
tr " " "," < filename
I can see some extra spaces at the last of each line. If you don't want a comma at the last then you can strip the extra space and convert. The below will do that
sed -e 's/^\(.*\) $/\1/' -e 's/ /,/g' filename