title: C# - StreamReader.ReadLine does not work properly!
body: <p>Simply I have been trying to implement what <code>BufferedStreamReader</code> does in Java. I have a socket stream open and just want to read it in a line-oriented fashion - line by line.</p>
  
  <p>I have the following server-code.</p>
  
  <pre><code>while (continueProcess)
          {
              try
              {
                  StreamReader reader = new StreamReader(Socket.GetStream(), Encoding.UTF8);
                  string command = reader.ReadLine();
                  if (command == null)
                      break;
  
                  OnClientExecute(command);
              }
              catch (Exception e)
              {
                  Console.WriteLine(e.ToString());
              }
          }
  </code></pre>
  
  <p>And the following client-code:</p>
  
  <pre><code>TcpClient tcpClient = new TcpClient();
          try
          {
              tcpClient.Connect("localhost", serverPort);
              StreamWriter writer = new StreamWriter(tcpClient.GetStream(), Encoding.UTF8);
              writer.AutoFlush = true;
              writer.WriteLine("login&gt;user,pass");
              writer.WriteLine("print&gt;param1,param2,param3");
          }
          catch (Exception e)
          {
              Console.WriteLine(e.ToString());
          }
          finally
          {
              tcpClient.Close();
          }
  </code></pre>
  
  <p>The server reads only the very first line (<code>login&gt;user,pass</code>) and then <code>ReadLine</code> returns null! </p>
  
  <p>What's the easiest way of achieving this line-oriented reader as it is in Java's <code>BufferedStreamReader</code>? :s</p>