title: while loop won't exit C
body: <p>This is a <strong>working snippet of a while loop</strong>:</p>
  
  <pre><code>while(total_bytes_read != fsize){
      while((nread = read(sockd, filebuffer, sizeof(filebuffer))) &gt; 0){
          if(write(fd, filebuffer, nread) &lt; 0){
              perror("write");
              close(sockd);
              exit(1);
          }
          total_bytes_read += nread;
          if(total_bytes_read == fsize) break;
      }
  }
  </code></pre>
  
  <p>This is an example of <strong>a NON working snippet of a while loop</strong>:</p>
  
  <pre><code>while(total_bytes_read != fsize){
      while((nread = read(sockd, filebuffer, sizeof(filebuffer))) &gt; 0){
          if(write(fd, filebuffer, nread) &lt; 0){
              perror("write");
              close(sockd);
              exit(1);
          }
          total_bytes_read += nread;
      }
  }
  </code></pre>
  
  <p>And also this, is an example of <strong>a NON working snippet of a while loop</strong>:</p>
  
  <pre><code>while(total_bytes_read &lt; fsize){
      while((nread = read(sockd, filebuffer, sizeof(filebuffer))) &gt; 0){
          if(write(fd, filebuffer, nread) &lt; 0){
              perror("write");
              close(sockd);
              exit(1);
          }
      }
       total_bytes_read += nread;
  }
  </code></pre>
  
  <p>I would like to know why into the 2 snippet above when <code>total_bytes_read</code> is equal to <code>fsize</code> the loop won't exit :O<br>
  Thanks in advance!</p>