title: unistd.h read() function: How to read a file line by line?
body: <p>What I need to do is use the read function from unistd.h to read a file
  line by line. I have this at the moment:  </p>
  
  <pre><code>n = read(fd, str, size);
  </code></pre>
  
  <p>However, this reads to the end of the file, or up to size number of bytes.
  Is there a way that I can make it read one line at a time, stopping at a newline?
  The lines are all of variable length.</p>
  
  <p>I am allowed only these two header files:  </p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;fcntl.h&gt;
  </code></pre>
  
  <p>The point of the exercise is to read in a file line by line, and
  output each line as it's read in. Basically, to mimic the fgets()
  and fputs() functions.</p>