while read -r line; do printf '%s\n' "$line" done < "$file"
NOTE: This reads each line of the file into the line variable.
while IFS= read -r line; do printf '%s\n' "$line" done < "$file"
NOTE: Very similar to the basic read, but adding usage of IFS.
The IFS (internal field separator) is often set to support reads.
#!/bin/bash while IFS='' read -r line || [[ -n "$line" ]]; do echo "Text read from file: $line" done < "$1"
NOTE: The -n checks if the string is not null.
This is the opposite of -z, which checks if a string is null, i.e. it has zero length.