title: Insert text in a text file at specific position
body: <p>I got a text file with e.g. 3 lines:</p>
  
  <pre class="lang-none prettyprint-override"><code>Example Text
  Some text here
  Text
  </code></pre>
  
  <p>I want to add some text directly after "here", so it will look like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>Example Text
  Some text hereADDED TEXT
  Text
  </code></pre>
  
  <p>My code, so far, looks like this, I used some of the code from <a href="https://stackoverflow.com/questions/16212127/add-a-new-line-at-a-specific-position-in-a-text-file">here</a>, but it doesn't seem to work.</p>
  
  <pre><code>List&lt;string&gt; txtLines = new List&lt;string&gt;();
  
  string FilePath = @"C:\test.txt";
  
  foreach (string s in File.ReadAllLines(FilePath))
  {
      txtLines.Add(s);
  }
  
  txtLines.Insert(txtLines.IndexOf("here"), "ADDED TEXT");
  
  using (File.Create(FilePath) { }
  
  foreach (string str in txtLines)
  {
      File.AppendAllText(FilePath, str + Environment.NewLine);
  }
  </code></pre>
  
  <p>My problem is:
  <code>txtLines.IndexOf("here")</code> returns <code>-1</code>, thus throwing a <code>System.ArgumentOutOfRangeException</code>.</p>
  
  <p>Can somebody tell me what I am doing wrong?</p>