anchor.diff:        }
       }
       return 0;
  +  }
  +
  +  void _dumpErrors(Iterable<String> errors) {
  +    if (argResults['write'] != null) {
  +      try {
  +        final RandomAccessFile resultsFile = new File(argResults['write']).openSync(mode: FileMode.WRITE);
  +        try {
  +          resultsFile.lockSync();
  +          resultsFile.writeStringSync(errors.join('\n'));
  +        } finally {
  +          resultsFile.close();
  +        }
  +      } catch (e) {
  +        printError('Failed to save output to "${argResults['write']}": $e');
  +      }
  +    }
     }
   
     List<File> _collectDartFiles(Directory dir, List<File> collected, {FileFilter exclude}) {
  
positive.code:     argParser.addFlag('preamble', help: 'Display the number of files that will be analyzed.', defaultsTo: true);
      argParser.addFlag('congratulate', help: 'Show output even when there are no errors, warnings, hints, or lints.', defaultsTo: true);
      argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
      argParser.addOption('dart-sdk', help: 'The path to the Dart SDK.', hide: true);
  
      // Hidden option to enable a benchmarking mode.
  
negative.code:         if (error.code != null)
            printTrace('error code: ${error.code}');
        }
  
        _dumpErrors(errors.map/*<String>*/((AnalysisError error) => error.toLegacyString()));
  
        // Print an analysis summary.
        String errorsMessage;
  