Fixed while loop to work in bash.

Something something forked subshell.
http://stackoverflow.com/questions/9985076/bash-populate-an-array-in-loop