Piping into a read
command causes the variables to be set in a subshell, which makes them inaccessible (indeed, they are gone) to the rest of your code. In this case, though, you don’t even need the for
loop or the second read
command:
while read -r a b; do
echo "$a" "$b"
done < text.txt