The statement:
for line in $result
performs word splitting on $result
to get each element that $line
should be set to. Word splitting uses the delimiters in $IFS
. Earlier in the script you set this to just ,
. So this loop will iterate over comma-separated data in $result
. Since there aren't any commas in it, it's just a single element.
If you want to split it by lines, do:
IFS="
"
for line in $result