Hi, I'm writing a email program and i need to make it so that when I delete a item from a listbox it also deletes from a text file. Right now all it does is delete it from the listbox and when the program is reloaded its still there. Any help would be appreciated. Thanks.

Dim arrEmailSelect As New List(Of Integer)
        Dim fileContents As String
        Dim thisEmail As New email
        Dim file As String = path & userName & "In.txt"
        Dim endMsgPos, startPos, endFieldPos As Integer
        Dim msgNum As Integer = 0
        fileContents = My.Computer.FileSystem.ReadAllText(file)
        startPos = 0
        endMsgPos = fileContents.IndexOf("^", startPos)

        For Each index As Integer In messageListBox.SelectedIndices
            arrEmailSelect.Add(index)
        Next

        Dim intCount As Integer = arrEmailSelect.Count - 1
        For intIndex As Integer = intCount To 0 Step -1
            messageListBox.Items.RemoveAt(arrEmailSelect(intIndex))

            If arrEmailSelect(intIndex) > 0 Then
                messageListBox.SelectedIndex = arrEmailSelect(intIndex) - 1
            Else
                messageListBox.SelectedIndex = 0
            End If
        Next
Do While endMsgPos <> -1
            startPos = fileContents.IndexOf("#", startPos + 1) + 1
            endFieldPos = fileContents.IndexOf("#", startPos)
            thisEmail.sender = fileContents.Substring(startPos, endFieldPos - startPos)
            startPos = endFieldPos + 1
            endFieldPos = fileContents.IndexOf("#", startPos)
            thisEmail.subj = fileContents.Substring(startPos, endFieldPos - startPos)
            startPos = endFieldPos + 1
            endFieldPos = fileContents.IndexOf("#", startPos)
            thisEmail.msgsent = fileContents.Substring(startPos, endFieldPos - startPos)
            startPos = endFieldPos + 1
            endFieldPos = fileContents.IndexOf("^", startPos)
            thisEmail.message = fileContents.Substring(startPos, endFieldPos - startPos)
inbox(msgNum) = thisEmail
            startPos = endFieldPos + 1
            endMsgPos = fileContents.IndexOf("^", startPos)
            msgNum = msgNum + 1
        Loop

How does the filecontent looks like? Can you post it?

filecontents looks like this:
user1#user2#msg1#4/22/2010 7:21:35 PM#Hello user^user1#user2#msg2#4/22/2010 7:21:53 PM#hello again^user1#user2#test#4/29/2010 1:07:31 PM#test^