OK...I finally figured out what is wrong. $5 keeps being $null at all times, but $4 changes to include a space separated list of numbers
So the first time the code is run, $4 returns 1
The second time, $4 returns 1 1
the third time, 1 1 1
4th time, 1 1 1 1
etc.
the number of space delimited tokens keeps increasing, but there's still only 4 items being returned. The 4th item just keeps returning more space delimited tokens.
Thanks to all who helped. Looks like my best method to resolve this problem is to use the tokenize command.