There’s no reason to use cat
here — it adds no functionality and spawns an unnecessary process.
while IFS= read -r line; do
echo "a line: $line"
done < file
To read the content of a file into a variable, use foo=$(<file)
.
(Note that this trims trailing newlines.)