Hey im trying to make a program that creates a new file and saves any amount of strings into the file, and basically the problem is that it only saves the last string that the user inputted. How do i make it save all the strings that the user inputs. Here is the code i have:
PrintWriter output; int line = 0; int i; int total; c.print ("Enter the number of words you're going to input: "); total = c.readInt (); c.println (); String[] word = new String [total]; do { try { output = new PrintWriter (new FileWriter ("DataIn.txt")); c.print ("Enter word " + (line + 1) + (": ")); word [line] = c.readString (); output.println (word [line]); line++; output.close (); } catch (IOException e) { new Message ("Error"); } } while (line < total);