title: How can I read and replace Strings line by line in a Text File?
body: <p>I have a text file that reads this:</p>
  
  <pre><code>INSERT INTO `shops` VALUES ('', '3', '1000000', '0');
  INSERT INTO `shops` VALUES ('', '3', '1000010', '0');
  INSERT INTO `shops` VALUES ('', '3', '1000020', '0');
  INSERT INTO `shops` VALUES ('', '3', '1000030', '0');
  INSERT INTO `shops` VALUES ('', '3', '1001000', '0');
  </code></pre>
  
  <p>Notice for each line the first key is ''. For each line, I want to find that '', and replace it with a number (starting with 1), then add 1 to it as it goes to the next line, Like so:</p>
  
  <pre><code>INSERT INTO `shops` VALUES ('1', '3', '1000000', '0');
  INSERT INTO `shops` VALUES ('2', '3', '1000010', '0');
  INSERT INTO `shops` VALUES ('3', '3', '1000020', '0');
  INSERT INTO `shops` VALUES ('4', '3', '1000030', '0');
  INSERT INTO `shops` VALUES ('5', '3', '1001000', '0');
  </code></pre>
  
  <p>I've been trying to do this for a couple of hours but I'm failing.</p>
  
  <p>Here is what I've been thinking of (I know this is far from right, but I'm not that savvy in c#, so maybe one of you can help me come up with the right code):</p>
  
  <pre><code>string text = File.ReadAllText("C:\\Users\\Donavon\\Desktop\\old.sql");
  
  int i = 0;
  text = text.Replace("('',", "('" + i + "',");
  i++;
  File.WriteAllText("C:\\Users\\Donavon\\Desktop\\new.sql", text);
  </code></pre>
  
  <p>Thanks for any help, It's greatly appreciated</p>