title: outputstream does not write the data as expected
body: <p>My server looks like this: </p>
  
  <pre><code>package marshexample;
  
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.io.Reader;
  import java.net.ServerSocket;
  import java.net.Socket;
  
  public class marshServer {
  
  private ServerSocket ses;
  private Reader br;
  private OutputStream os;
  
  public marshServer() {
  
      StringBuilder sb = new StringBuilder();
  
      try  {
          ses = new ServerSocket(7824);
          Socket s = ses.accept();
          br = new InputStreamReader(s.getInputStream());
          char[] request = new char[6];
          int count = br.read(request);
  
          while (!sb.toString().contains("project")) {
  
              sb.append(new String(request, 0, count));
              count = br.read(request);
              System.out.println(sb.toString());
          }
          System.out.println(sb);
  
          os = s.getOutputStream();
          os.write("string from server".getBytes());
          os.write("empty line".getBytes());
          os.flush();
  
  
      } catch (Exception e) {
          e.printStackTrace();
      }
      System.out.println(sb);
  
  }}
  </code></pre>
  
  <p>The issue is I have to add the string os.write("empty line".getBytes()); in order to make it work correctly. Without this string the massage is not fully sent to the client. (The same situation is with client). So why flush method does not solve this problem? Thank you for any ideas! </p>