My Printwriter method is not writing to a text file. the code runs fine it displays the text on screen but nothing appears in the text file.
public void run() throws IOException
{
Scanner sc = new Scanner(System.in);
boolean cont = true;
while (cont)
{
System.out.println("Enter your line text");
String line = sc.nextLine();
if ("*".equals(line))
{
cont = false;
}
String result = shorthand(line);
System.out.println(result);
PrintWriter pw = new PrintWriter(new FileWriter("outfile.txt"));
pw.println(result);
pw.close();
}
}