Question: in my web page i am using two textboxes to add record in a text file.
but the problem is that every time when i insert new record,previous record in the text file automatically delete,and the text file contains only the current record.
kindly help me fix this issue.
Thanks.

```
        <asp:TextBox ID="txt1" runat="server"></asp:TextBox><br />
        <asp:TextBox ID="txt2" runat="server"></asp:TextBox><br />
        <asp:Button ID="btn" runat="server" Text="save" OnClick="btn_Click" />

```

and my code behind is like this

```
 protected void btn_Click(object sender, EventArgs e)
    {
        TextWriter tw = new StreamWriter(Server.MapPath("date.txt"));
        tw.WriteLine(txt1.Text + txt2.Text + System.DateTime.Now);
        tw.Close();
    }

```

Answer: 
Update your TextWriter to enable appending, like this:

```
TextWriter tw = new StreamWriter(Server.MapPath("date.txt"), true);

```
i have also done like this and it is also working well

```
 protected void btn_Click(object sender, EventArgs e)
    {
        string text = txt1.Text + "" + txt2.Text+""+System.DateTime.Now;
        string path=Server.MapPath("date.txt");            
        File.AppendAllText(path, text + "\n");            
    }

```