Fix looping over string of space-separated words