Mapfile is a convenient way to read lines from a file into an indexed array, not as portable as read but slightly faster. By using for loop you avoid creating a subshell.
#!/bin/bash
mapfile -t < file.txt
for line in "${MAPFILE[@]}"; do
echo $line
done
Keep in mind when using pipelines, it will put the while loop in a subshell. Changes inside the while loop like variables will not propagate to outer part of the script.
Example:
#!/bin/bash
a=0
printf %s\\n {0..5} | while read; do
((a++))
done
echo $a # 'a' will always be 0.
(Better solution):
#!/bin/bash
b=0
while read; do
((b++))
done < <(printf %s\\n {0..5})
echo $b # 'b' equal to 6 (works as expected).