Read input from file

#!/bin/bash
cat myfilename.txt |     # Supply input from a file.
while read line          # As long as there is another line to read ...
do
        echo "$line"
done
 
# OR: Last line will be read.
cat myfilename.txt |     # Supply input from a file.
while IFS='' read -r LINE || [[ -n "$LINE" ]]; do
  echo ${LINE}
done

http://stackoverflow.com/a/10929511

Note: If you add a counter within the above loop will not work, see http://stackoverflow.com/questions/16854280/modifying-variable-inside-while-loop-is-not-remembered