I usually use the read command to read an input file to the shell script line by line. An example code such as the one below yields a wrong result if a new line isn\'t inser
One line answer:
IFS=$'\n'; for line in $(cat file.txt); do echo "$line" ; done