title: Bash while loop with done < $1
body: <p>I'm a bit confused by the <code>done &lt; $1</code> notation.</p>
  
  <p>I'm trying to write a program "sumnums" that reads in a file called "nums" that has a couple rows of numbers. Then it should print out the rows of the numbers followed by a sum of all the numbers.</p>
  
  <p>Currently I have:</p>
  
  <pre><code>#!/bin/bash
  sum=0;
  while read myline
  do  
    echo "Before for; Current line: \"$myline\""
  done
  for i in $myline; do  
    sum=$(expr $sum + $i)
  done &lt; $1    
  echo "Total sum is: $sum"
  </code></pre>
  
  <p>and it outputs the list of the numbers from nums correctly then says 
  <code>./sumnums: line 10: $1: ambiguous redirect</code>, then outputs <code>Total sum is: 0</code>. </p>
  
  <p>So somehow it isn't adding.  How do I rearrange these lines to fix the program and get rid of the "ambiguous redirect"?</p>