Convert 2D polyline to 3D in DXF

2D CAD programs can generate only 2D polylines. Below is simple sample code to add the third coordinate and resave the file. DXF files.

Imports System.IO
Module Module1
Sub Main()
    AddZ()

End Sub

Private Sub AddZ()
    Dim fs As New StreamReader("u:\temp\poly1.dxf")
    Dim s1 As String = fs.ReadToEnd
    fs.Close()

    Dim fw As New StreamWriter("u:\temp\poly1-2.dxf")
    Dim s2() As String
    s2 = Split(s1, vbNewLine)

    Dim l1 As New List(Of String)

    Dim i As Integer = 0
    Dim s3, s4, s5, s6, s7 As String

    Do
        s3 = s2(i)
        If s3.Trim = "10" Then
            l1.Add(s3)
            i += 1
            l1.Add(s2(i))
            i += 1
            s3 = s2(i)
            If s3.Trim = "20" Then
                l1.Add(s3)
                i += 1
                l1.Add(s2(i))
                l1.Add("30")
                l1.Add("0")
            Else
                l1.Add(s3)

            End If
        Else
            l1.Add(s3)
        End If
        i += 1
    Loop Until i >= s2.Length

    For Each l2 As String In l1
        s5 += l2 & vbNewLine
    Next

    fw.WriteLine(s5)
    fw.Close()

    MsgBox("done")

End Sub
End Module