Is it possible for me to use a BufferedWriter (or any writer class for that matter) to output a new line to a text file during each iteration of an infinite loop until the program is stopped? To my understanding, the BufferedWriter.close() command must be called for the text to be saved onto the file, but if the writer is closed within the loop, the program will throw an exception - obviously, if the writer is set to close outside the loop, the statement is unreachable. Thanks in advance for any help. 

Here's the relevant code:

```
             int count = 0;
             BufferedWriter out = new BufferedWriter(new FileWriter("myTextFile.txt"));
             while (true) 
             {

                if(count == 0){
                    out.write(myString);
                    out.newLine();
                    System.out.println(myString);
                } else {
                    out.append(myString);
                    out.newLine();
                    System.out.println(myString);

                }
                System.out.println("count = " + count);
                count++;
                out.flush();
                out.close();                   
             }

```