Exercise
Appending to a text file
Objetive
Create a program to ask the user for several sentences (until they just press Enter) and store them in a text file named "sentences.txt". If the file exists, the new content must be appended to its end.
Code
Imports System
Imports System.IO
Class Sentences
Private Shared Sub Main(ByVal args As String())
Dim myFile As StreamWriter = File.AppendText("file.txt")
Dim line As String
Do
Console.Write("Enter a sentence: ")
line = Console.ReadLine()
If line <> "" Then myFile.WriteLine(line)
Loop While line <> ""
myFile.Close()
End Sub
End Class