title: write() to stdout and printf output not interleaved?
body: <pre><code>#include &lt;stdio.h&gt;
  #define MAXLEN 256
  
  int main() {
    int n;
    char buf[MAXLEN];
    while((n = read(0,buf,sizeof(buf))) != 0){
      printf("n: %d:",n);
      write(1,buf,n);
    }
    return 1;
  }
  </code></pre>
  
  <p>The output of the program (where the first <code>read</code> and first <code>write</code> is typed by the user and echoed by the terminal) is: </p>
  
  <pre><code>read
  read
  write
  write
  n: 5:n: 6:
  </code></pre>
  
  <p>The output of printf comes after pressing Ctrl+D at the standard input and not along with the subsequent reads. Why does this happen?</p>