title: why in this piece of code, fgets returns null when it shouldn't?
body: <p>I am coding a program that a piece of it is as below:</p>
  
  <pre><code>#define BUFFSIZE 2000
  while( fgets(buff, BUFFSIZE - 1, fPtr) != NULL)
  {
      //how many words is read from the source file in the current line
      int wordread = 0;
  
      word = strtok(buff, punc);
      //one word read
      while( word != NULL)
      {
          //sorting
          int k = 0;
          while(strcmp(word, words[k]) &lt; 0)
              k++;
          if(strcmp(word, words[k]))
          {
              last++;
              for(int l = last; l &gt;= 0; l--)
                  strcpy(words[l + 1],words[l]);
              strcpy(words[wordread],word);
          }
          index[last][lineread]++;
  
          wordread++;//go to next word
  
          word = strtok(NULL, punc);
      }
      lineread++;//go to next line
  }
  </code></pre>
  
  <p>but I understood that the compiler doesn't go inside the first while</p>
  
  <pre><code>while( fgets(buff, BUFFSIZE - 1, fPtr) != NULL)
  </code></pre>
  
  <p>I understood that this fgets returns NULL at first. but fPtr has an correct address and in the address there is a file of some data. </p>
  
  <pre><code>FILE *fPtr = fopen(argv[1], "r");
  </code></pre>
  
  <p>and the definition of buff is:</p>
  
  <pre><code>char buff[BUFFSIZE];
  </code></pre>
  
  <p>can anyone help? if the whole of the code is needed, tell me to write all of it.</p>