Do not skip the last line of files ending without line terminator

On the last line of a file without line terminator,
read returns a non-zero status which prevents the
body of the loop from running. The text read, however,
is correctly set in the given variable.

The solution is thus to test the contents of the variable
instead or in addition to testing the return value of read.

Reference:
Shell script read missing last line
Answer by Gordon Davisson, 2012-10-16
http://stackoverflow.com/a/12919766