When I do something like this:
for line in `cat some_file` do <whatever with> $line done
It works fine when there are no spaces in the lines in $line. But if there are spaces, it does <whatever> to each expression between the spaces.
Two neat tricks for coping with is.
1. Change the internal field separator ($IFS) to only separate on newline:
And carry on with your normal loop.
2. Use a read in a while loop instead:
cat filename | while read line; do echo $line done