public static void writeFile(String fileName) {
      if (fileName == null)  // Go back to reading standard output
         writeStandardOutput();
      else {
         PrintWriter newout;
         try {
            newout = new PrintWriter(new FileWriter(fileName));
         }
         catch (Exception e) {
            throw new IllegalArgumentException("Can't open file \"" + fileName + "\" for output.\n"
                           + "(Error :" + e + ")");
         }
         if (!writingStandardOutput) {
            try {
               out.close();
            }
            catch (Exception e) {
            }
         }
         out = newout;
         writingStandardOutput = false;
         outputFileName = fileName;
         outputErrorCount = 0;
      }
   }