It looks like your code got truncated, but it sounds like the classic pipe-to-read problem.
$ echo hi | read x
$ echo $x
$ # Nothing!
$ read x <<< hi
$ echo $x
hi
Basically, a pipe creates an implicit subshell. To avoid it, either avoid the pipe:
while read foo; do things; done < <(process substitution)
Or explicitly create the subshell so you can control the scope:
inputcommand | ( while read foo; do things; done;
# variables still assigned as long as you're in the subshell
)