title: While loop in Bash script?
body: <p>I'm not used to writing Bash scripts, and Google didn't help in figuring out what is wrong with this script:</p>
  
  <pre><code>#!/bin/bash
  while read myline
  do
  done
  
  echo "Hello"
  while read line
  do
  done
  
  exit 0
  </code></pre>
  
  <p>The output I get is:</p>
  
  <pre><code>./basic.agi: line 4: syntax error near unexpected token 'done'
  ./basic.agi: line 4: 'done'
  </code></pre>
  
  <p>and my <code>bash</code> version is:</p>
  
  <pre><code>GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
  </code></pre>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p>Edit: The script works OK when the while loop isn't empty.</p>
  
  <p>While I'm at it... I expected to exit the loop when the user typed nothing, ie. simply hit the Enter key, but Bash keeps looping. How can I exit the loop?</p>
  
  <pre><code>while read myline
  do
          echo ${myline}
  done
  
  echo "Hello"
  while read line
  do
          true
  done
  
  exit 0
  </code></pre>