Here is the code snippet that I will use in the future when I want to read in a file line by line

#!/bin/bash
while read LINE ; do
    echo $LINE;
done < file.txt;

The following is a possibility too, but, any variable used on the inside of the while loop will not be available on the outside. This is because below the while loop is executed in a sub-shell because of the pipe.

#!/bin/bash
cat file.txt |
while read LINE ; do
    echo $LINE
done