title: StreamReader - ReadLine from Socket doesn't stop
body: <p>I'm trying to communicate with a server. </p>
  
  <p>This is my simple code:</p>
  
  <pre><code>System.Net.Sockets.TcpClient sock = new System.Net.Sockets.TcpClient();
  string outputString = string.Empty;
  sock.Connect("stack.overflow", 80);
  
  NetworkStream ns = null;
  StreamReader sr = null;
  StreamWriter sw = null;
  
  ns = sock.GetStream();
  sr = new StreamReader(ns);
  sw = new StreamWriter(ns) { NewLine = "\r\n", AutoFlush = true };
  ns.ReadTimeout = 10;
  sw.WriteLine("send data to server");
  sw.Flush();
  
  outputString = sr.ReadLine();
  while (!string.IsNullOrEmpty(outputString))
  {
      System.Diagnostics.Debug.WriteLine(outputString);
      outputString = sr.ReadLine();
  }
  </code></pre>
  
  <p><em>(I know my code has room for improvement. It kept it simple for my test)</em> </p>
  
  <p>Everything works fine beside the ReadLine(). 
  It doesn't do what I'm expecting it to do. </p>
  
  <p>It reads all lines from the server and after the last line it just endlessly waits for a new line. At least for me it seems like it is waiting.</p>
  
  <p>I thought it would stop after the last line and return null or something else.</p>
  
  <p>Can someone explain me what the best practice is to get all lines from the server and move on? </p>