How do I add a value to my txt file one time only?
<p>I have this code, which adds a line into my Students.txt, however, everytime I compile and run the code, it does it again. What code can I add so that the new record is only added once?</p>

<pre><code>string newLastName = "'Constant";
string newRecord = "(LIST (LIST 'Constant 'Malachi 'D ) '1234567890 'mdconstant@mail.usi.edu 4.000000 )";
string line;
string lastName;
bool insertionPointFound = false;

for (int i = 0; i &lt; lines.Count &amp;&amp; !insertionPointFound; i++)
{
    line = lines[i];
    if (line.StartsWith("(LIST (LIST "))
    {
        values = line.Split(" ".ToCharArray());
        lastName = values[2];
        if (newLastName.CompareTo(lastName) &lt; 0)
        {
            lines.Insert(i, newRecord);
            insertionPointFound = true;
        }
    }
}

if (!insertionPointFound)
{
    lines.Add(newRecord);                          //This record is always added, making the file longer over time 
                                                    //if it is not deleted each time from the Students.txt file in 
}                                                  //the bin folder.

File.WriteAllLines("Students.txt", lines);
</code></pre>
