title: Reading a file line by line and splitting the string into tokens in c
body: <p>I am reading a file line by line and splitting the string into tokens. </p>
  
  <pre><code>int main()
  {
      FILE* fp;
      char  line[255];
  
      fp = fopen("file.txt" , "r");
      while (fgets(line, sizeof(line), fp) != NULL)
      {   
          char val1[16];
          char val2[9];
  
          strcpy(val1, strtok(line, ","));
          strcpy(val2, strtok(NULL, ","));
  
          printf("%s|%s\n", val1, val2);          
      }
  }
  </code></pre>
  
  <p>My input file content (file.txt)</p>
  
  <pre><code>182930101222, KLA1512
  182930101223, KLA1513
  182930101224, KLA1514
  182930101225, KLA1515
  </code></pre>
  
  <p>When I print get </p>
  
  <pre><code> | KLA1512
  </code></pre>
  
  <p>Instead of</p>
  
  <pre><code>182930101222| KLA1512
  </code></pre>
  
  <p>What is the issue ? </p>