title: Bash while loop that reads file line by line
body: <p>There are two ways of reading a file line by line that I want to discuss here:</p>
  
  <pre><code>#!/bin/bash    
  
  while read line    
  do    
      echo-e "$ line \ n"    
  done &lt;file.txt
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#!/bin/bash    
  exec 3&lt;file.txt
  
  while read line    
  do    
      echo-e "$ line \ n"    
  done
  </code></pre>
  
  <p>So first version works fine but I don't understand the mechanism of working while loop with the file. But the mechanism of the second version I understand. But here I don't understand why it hangs and does not print anything.</p>