title: Iterating through each token of a line within a file in C
body: <p>I am trying to parse through each token within each line of a file. But I am getting an infinite loop in the inner while loop. Why is this? It's not because of the "true" condition as I have break statements within the while loop. I think I am not correctly
  checking when I get to the end of a line.</p>
  
  <pre><code>char currentLine[MAXIMUM_LINE_LENGTH + 1]; // + 1 for terminating char
  
      while (true) {
          if (fgets(currentLine, MAXIMUM_LINE_LENGTH, inputFilePointer) == EOF ) {
              break;
          } else { // we need to parse the currentLine
              // check if the currentLine is too long
              if (strlen(currentLine) &gt; MAXIMUM_LINE_LENGTH) {
                  // print to the file that the currentLine being parsed it too long
                  printf(
                          "WARNING: currentLine is too long and must be &lt;= 256 characters\n");
                  continue; // move on to next line in input file
              } else { // currentLine has valid length
                  while (true) {
                      // iterate through each token within the currentLine and parse the token
                      char *currentToken = strtok(currentLine, " $,\t");
                      printf("currentToken = %s", currentToken);
                                      // do something with currentToken
  
                      if (currentToken == NULL || *currentToken == '#') {
                          break; // &lt;== ERROR This break statement is never getting hit WHY?
                      }
                  }
              }
          }
      }
  </code></pre>