//== Write a text-file ==
//  Inputs strings from the user, and writes them into a text-file
//=======================================================================

 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 import java.io.*;

 public class WriteFile extends EasyApp     // EasyApp contains IBIO + standard constructor stuff
 public static void main(String[] args)  
   {  new WriteFile()}                    // Instantiate an object = start the program
   
   public WriteFile()
   {   String filename = input("File Name");           
       
       try
       {              
           PrintWriter file                                  
             new PrintWriter(new FileWriter(filename));    // open file for writing
           
           String info = "";                  
           
           while (!info.equals("X"))                         // stop when user types "X"
           {
               info = input("Type another string (X to quit):");
               if (!info.equals("X"))                        // Don't save the "X"
               {  file.println(info);  }                     // write string into file
           }
           file.close();                                     // close file
       }
       catch (IOException e)                                 // handle IO errors, such as
       {   output(e.toString())}                           //   write-protected file
   }
}