I am writing a little utility to generate some SQL files. I have a file which is generated from a string array of 400+ elements. It stops writing (without throwing an error) at arround 1000 characters or 380 lines. I am clearly missing something here. Question is what? I've tried (the remed lines of) flush but that seems to have no effect.

<code>
Dim fsExec As New FileStream(sPath & sExecFileName & ".sql", FileMode.Create, FileAccess.Write)
'declaring a FileStream and creating a document file with
'access mode of writing
Dim sExec As New StreamWriter(fsExec)

Dim iChar As Integer = 0
For icount = 0 To miExecLineCount
iChar += msExec(icount).Length
If icount = 382 Then
icount = icount
End If
'writing text to the newly created file
sExec.WriteLine(msExec(icount))
'If icount Mod 100 = 50 Then
' sExec.Flush()
' fsExec.Flush()
'End If
lblMessage.Text = msExec(icount)
lblMessage.Refresh()
Application.DoEvents()
Next
</code>