private static void outputError(String message) {  // Report an error on output.
      if (writingStandardOutput) {
         System.err.println("Error occurred in TextIO while writing to standard output!!");
         outputErrorCount++;
         if (outputErrorCount >= 10) {
            outputErrorCount = 0;
            throw new IllegalArgumentException("Too many errors while writing to standard output.");
         }
      }
      else if (outputFileName != null){
         throw new IllegalArgumentException("Error occurred while writing to file \"" 
               + outputFileName+ "\":\n   " + message);
      }
      else {
         throw new IllegalArgumentException("Error occurred while writing to output stream:\n   " + message);
      }
   }