title: Why doesn't write() work properly?
body: <pre><code>int main() {
      int in = STDIN_FILENO;
      int out = STDOUT_FILENO;
      char word[100];
      int count;
  
      while ((count = read(in, word, 100)) != 0) {
          write(out, word, strlen(word));
          memset(word, 0, 255);
          count = read(in, word, 5);
      }
  }
  </code></pre>
  
  <p>In the console I got</p>
  
  <pre><code>hello world
  hello world
  hello stackoverflow
   stackoverflow
  abcd
  efgh
  efgh
  </code></pre>
  
  <p>Why isn't this program echoing back exactly as it was written?</p>