What's happening is, the read
command fails when the input is not terminated with a newline. Since the newline character is missing at the end of your file, the read
fails, so the last iteration of the while
loop is skipped.
If you don't want to / cannot make sure that your input file has a newline at the end, you can group your cat
with an echo
to give the appearance of an input terminated by newline, for example like this:
{ cat hello; echo; } | while read a b c d; do
echo $a,$b,$c,$d
done
or like this:
(cat hello; echo) | while read a b c d; do
echo $a,$b,$c,$d
done