Try this,
Imports System.IO
Imports System.Diagnostics
Public Sub writeToFile(ByVal strMsg As String)
Dim strLogPath As String = ""
Dim fs As FileStream
Dim sw As StreamWriter
strLogPath = filepath
If File.Exists(strLogPath) = True Then
fs = File.Open(strLogPath, FileMode.Append, FileAccess.Write)
sw = New StreamWriter(fs)
Else
fs = File.Create(strLogPath)
sw = New StreamWriter(fs)
End If
sw.WriteLine(strMsg)
sw.Close()
fs.Close()
End Sub