I am hoping someone can explain the following result I am receiving with my simple script. I cannot understand why only the last variable being echoed comes out properly.
#/bin/bash
MYFILE=$1
while IFS= read -r line || [ -n "$line"]
do
echo "Ref will be ${line}.txt and label is ${line}"
done < $1
After I run it:
$ ./myscript.sh myfile.txt
.txt and label is KAT1
.txt and label is KAT2
Ref will be KAT3.txt and label is KAT3
Why are the all the lines before the last line only half being processed properly???