title: Read last line of file in bash script when reading file line by line
body: <p>I am writing a script to read commands from a file and execute a specific command. I want my script to work for either single input arguments or when an argument is a filename which contains the arguments in question.</p>
  
  <p>My code below works except for one problem, it ignores the last line of the file. So, if the file were as follows.</p>
  
  <p>file.txt</p>
  
  <pre><code>file1
  file2
  </code></pre>
  
  <p>The script posted below only runs the command for file.txt</p>
  
  <pre><code>for currentJob in "$@"
  do
      if [[ "$currentJob" != *.* ]]  #single file input arg
      then
          echo $currentJob
          serverJobName="$( tr '[A-Z]' '[a-z]' &lt;&lt;&lt; "$currentJob" )"  #Change to lowercase
                                                                     #run cURL job
          curl -o "$currentJob"PisaInterfaces.xml http://www.ebi.ac.uk/msd-srv/pisa/cgi-bin/interfaces.pisa?"$serverJobName"
      else  #file with list of pdbs
          echo "Reading "$currentJob
          while read line; do
              echo "-"$line
              serverJobName="$( tr '[A-Z]' '[a-z]' &lt;&lt;&lt; "$line" )"
              curl -o "$line"PisaInterfaces.xml http://www.ebi.ac.uk/msd-srv/pisa/cgi-bin/interfaces.pisa?"$serverJobName"
          done &lt; "$currentJob"
      fi
  done
  </code></pre>
  
  <p>There is, of course, the obvious work around where after the while loop I repeat the steps for inside the loop to complete those commands with the last file, but this is not desirable as any changes I make inside the while loop must be repeated again outside of the while loop. I have searched around online and could not find anyone asking this precise question. I am sure it is out there, but I have not found it.</p>
  
  <p>The output I get is as follows.</p>
  
  <pre><code>&gt;testScript.sh file.txt
  Reading file.txt
  -file1
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  100  642k    0  642k    0     0   349k      0 --:--:--  0:00:01 --:--:--  492k
  </code></pre>
  
  <p>My bash version is 3.2.48</p>