title: Deleting a line of text in a text file by its context
body: <p>I have a function for a pet store inventory program. So far, it will list the inventory, and add an item to the inventory. Now I'm trying to delete an item by its productNumber(first value store in csv text file).  I changed my code around I just need a litte help with the condition. I need it to scanf the productNumber and delete the line by its product number.</p>
  
  <p>QUESTION: how do I get the condition to look for the productNumber in the text file ,so I can delete that line in the text file.</p>
  
  <p>I need some help please! I have a csv text file that is set up as the following structure:</p>
  
  <pre><code>struct inventory_s
  {
      int productNumber;
      float mfrPrice;
      float retailPrice;
      int numInStock;
      char liveInv;
      char productName[PRODUCTNAME_SZ +1];
  };
  
  /*Originalfile I'm trying to copy and delete from looks like*/
  
  1000,1.49,3.79,10,0,Fish Food
  2000,0.29,1.59,100,1,AngelFish
  2001,0.09,0.79,200,1,Guppy
  5000,2.40,5.95,10,0,Dog Collar Large
  6000,49.99,129.99,3,1,Dalmation Puppy
  
  /*function looks like*/
  
  int deleteProduct(void)
  {
  
      struct inventory_s newInventory;
      char line[50];
      //int del_line, temp = 1;
  
      FILE* originalFile = fopen("inventory.txt", "r"); //opens and reads file
      FILE* NewFile = fopen("inventoryCopy.txt", "w"); //opens and writes file
      if(originalFile == NULL || NewFile == NULL)
      {
         printf("Could not open data file\n");
         return -1;
      }
      printf("Please enter the product number to delete:");
      sscanf(line," %i", &amp;newInventory.productNumber);
  
      while(fgets(line, sizeof(line), originalFile) !=NULL)
      {
          if (!(&amp;newInventory.productNumber))
          {
              fputs(line, NewFile);
          }
      }
  
  
  
      fclose(originalFile);
      fclose(NewFile);
  
      return 0;
  }
  
  
  
  /*Input from user: 1000*/
  
  /* What needs to happen in Newfile*/
  
  2000,0.29,1.59,100,1,AngelFish
  2001,0.09,0.79,200,1,Guppy
  5000,2.40,5.95,10,0,Dog Collar Large
  6000,49.99,129.99,3,1,Dalmation Puppy
  </code></pre>