title: Ada.Text_IO.End_Of_File buffering side effect
body: <p>I am trying to build an REPL in Ada after not having touched the language for many years.  </p>
  
  <p>If I check for END_OF_FILE in the code, the way that Text_IO buffers input and output changes.  I remember this being the case but cannot find a description of why or how to deal with this.  (I suspect this is a difference between terminal IO and file based IO)</p>
  
  <p>Can anyone point me to a description of why Text_IO behaves this way?  </p>
  
  <pre><code>with Ada.Text_IO; use Ada.Text_IO;
  with Ada.Exceptions; use Ada.Exceptions;
  with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
  
  
  procedure fred is
          Buffer: Unbounded_String := Null_Unbounded_String;
          L : integer := 0;
  begin
          -- while (not End_Of_File)
          loop
                  L := L+1;
                  put("--&gt; ");
                  Buffer := To_Unbounded_String(Get_Line);
                  Put_Line(Integer'image(L) &amp; " " &amp; to_String(Buffer));
          end loop;
  exception
          when END_ERROR =&gt;
                  put_line("");
                  put_line("Bye ...");
  end fred;
  </code></pre>
  
  <p>Running this code as-is gives</p>
  
  <pre><code>--&gt; a
   1 a
  --&gt; s
   2 s
  --&gt; d
   3 d
  --&gt;
  Bye ...
  </code></pre>
  
  <p>If I uncomment the <strong>while</strong> statement I get</p>
  
  <pre><code>a
  --&gt;  1 a
  s
  --&gt;  2 s
  d
  --&gt;  3 d
  </code></pre>