Outline
When reading the contents of the file, if the file format is not UNIX, and the last line of the file is not in a blank line in the script by while read cycle, then the time to read the last line is always unable to process the data correctly, the reason is because the carriage return line feed character issues, so in order to solve this problem, in simple pretreatment at the end of the file to determine whether there is a newline.
tail -n1 <your file> | wc -l
1 there is represented an output newline 0 output No Wrap
solve
eg:
if [ $(tail -n1 <your file> | wc -l) -eq 1 ];then
echo "Newline at the end of the file"
fi