title: How to read from user within while-loop read line?
body: <p>I had a bash file which prompted the user for some parameters and used defaults if nothing was given. The script then went on to perform some other commands with the parameters. 
  This worked great - no problems until most recent addition. </p>
  
  <p>In an attempt to read the NAMES parameter from a txt file, I've added a while-loop to take in the names in the file, but I would still like the remaining parameters prompted for. </p>
  
  <p>But once I added the while loop, the output shows the printed prompt in get_ans() and never pauses for a read, thus all the defaults are selected. </p>
  
  <p>I would like to read the first parameter from a file, then all subsequent files from prompting the user. </p>
  
  <p>What did I break by adding the while-loop?</p>
  
  <pre><code>cat list.txt | 
  while read line
  do 
    get_ans "Name" "$line"
    read NAME &lt; $tmp_file
  
    get_ans "Name" "$line"
    read NAME &lt; $tmp_file
  done
  
  function get_ans
  {
    if [ -f $tmp_file ]; then
      rm $tmp_file
  
    PROMPT=$1
    DEFAULT=$2
  
    echo -n "$PROMPT [$DEFAULT]: "
    read ans
    if [ -z "$ans" ]; then
      ans="$DEFAULT"
    fi
    echo "$ans" &gt; $tmp_file
  }
  </code></pre>
  
  <p>(NOTE: Code is not copy&amp;paste so please excuse typos. Actual code has function defined before the main())</p>