I want to replace the second part of the string line of my .txt file. My .txt is:

```
admin|admin
ruiliberal|123456789

```

And I want to replace it like this for example:

```
admin|12345
ruiliberal|123456789

```

My code is:

```
string dirConta = Environment.CurrentDirectory + "/Bd/contas.txt";

private void buttonGravaPass_Click(object sender, EventArgs e)
{
    string[] lines = File.ReadLines(dirConta).ToArray();

    for (int i = 0; i < File.ReadAllLines(dirConta).Count(); i++)
    {

        string[] parts = lines[i].Split(new char[] { '|' });
        if (parts[0] == Users.user)
        {
            lines[i] = lines[i].Remove(lines[i].Length - 5);
            lines[i] = lines[i] + "12345";
        }
        File.WriteAllText(dirConta, lines[i]);
    }
}

```

This doesn´t work, it deletes the last line.