I am making a program that accepts 10 strings and send them to a text file. But, my problem is that it is just overwriting any previous values present in the file. Any ideas how to prevent it overwriting? My program is as follows:
import java.io.*;
public class TEST
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
        int a;
        String x;
        for (a=1; a<=10; a++)
        {
            System.out.println("Please enter a word.");
            x=in.readLine();
            PrintStream konsole = System.out;
            System.setOut(new PrintStream("TEST.txt"));
            System.out.println(x);
            System.setOut(konsole);
        }
        System.out.println("DONE");
    }
}
 
     
    