title: How to remove a line from csv file if it contains a specific word
body: <p>I am trying to remove a line from csv file if it contains the word. But instead, it deletes everything inside CSV. You can find my code attached below. I am more or less sure that my for loop is incorrect but I couldn't make any other logic.</p>
  <pre><code>[HttpPost(&quot;Delete{studentIndex}&quot;)]
          public IActionResult DeleteStudent([FromRoute] string studentIndex)
          {
              string[] values = System.IO.File.ReadAllLines(&quot;data.csv&quot;);
              StreamWriter Writer = new StreamWriter(&quot;data.csv&quot;, false);
              
              for (int i = 0; i &lt; values.Length; i++)
              {
                  if (values[i].Contains(studentIndex))
                  {
                      Writer.WriteLine(values[i].Replace(values[i], &quot;&quot;));
                  }
              }
  
              Writer.Close();
  
              return Ok();
          }
  </code></pre>