title: strtok_r throwing in random new lines
body: <p>Hi everyone I've got a problem with <code>strtok_r</code> throwing in random new lines, and was wondering if anyone could show me why it would be doing that? From my understanding, it is printing a new line when the input has a new line at the end, but this doesn't happen every time and I'm not sure why. My motivation is to have an input string of multiple words, and for <code>strtok_r</code> to store the words individually into an array (storage).</p>
  <pre><code>char delimit[] = &quot; \t\r\n\v\f&quot;;
  char *tempword; //temporary word until it is stored into the temp array
  for (int r = 0; r &lt; line_count; r++) {
      int counting = 0; //location of where tempword is stored in temp[counting]
      tempword = strtok_r(ptrarray[r], delimit, &amp;ptrarray[r]);
      while (tempword != NULL &amp;&amp; strcmp(tempword,&quot;\n&quot;) != 0 &amp;&amp; strcmp(tempword, &quot;\0&quot;) != 0) {
          printf(&quot;temp: %s\n&quot;, tempword);
          storage[r][counting] = strdup(tempword); 
          tempword = strtok_r(NULL, &quot; &quot;, &amp;ptrarray[r]);
          counting++;   
      }
      storage[r][word_count] = NULL; //last argument = NULL for execvp function
  }
  </code></pre>