Hello, I am new to the VB Forums. I searched the forums for an answer, but could not find one that exactly fit my issue. I apologize if I missed it.

What I am doing is I'm pulling strings of text from a backslash-delimited text file and throwing it into a (Of String, Array) dictionary. This info is then displayed, added to, removed from, through the use of the form. Changes to the entries (new, old, or otherwise) then need to be written back in the same delimited format to the text file.

Everything seemingly works aside from one thing: every time I write back to the text file, its contents are erased and nothing is written in its place.

Here is my StreamWriter code:
Code:
    Public Function WriteDataToFile(ByVal FilePath As String) As Boolean
        'write all data back to the inventory file

        Dim w = New StreamWriter(FilePath)
        Dim entry As New KeyValuePair(Of String, Array)

        For Each entry In Inventory.dict
            w.Write(CStr(entry.Key & "\" & entry.Value(0, 0) & "\" & entry.Value(1, 0) & _
                         "\" & entry.Value(2, 0) & "\" & entry.Value(3, 0) & "\" & entry.Value(4, 0)))
            w.WriteLine()
        Next

        Return True
        w.Close()
    End Function
Here is my form:


My 'close' button handler (changes are saved when this is clicked to close the form):
Code:
    Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
        'write data back to file
        InvFile.WriteDataToFile(FilePath)

        'close application
        Close()

    End Sub
I can provide further code if it would help, such as for adding new entries, displaying entries, etc. I just didn't want to add it right from the start and make this post unnecessarily more visually cluttered.

All of my fields are of type String. It seemed to make the strictly typed dictionary happier. The first delimited entry in each entry of the text file is the key, the following 5 go into the array. That's all I can think of for now.

Thank you in advance for trying to help!