def checkAndEnsureOutputFileUnchanged(outFile, oldFile)
      if File.exists? oldFile
        oldFileContents = File.read(oldFile)
        newFileContents = File.read(outFile)
        if oldFileContents != newFileContents
          newFileName = outFile + ".new"
          File.rename(outFile, newFileName)
          File.rename(oldFile, outFile)
          raise UnexpectedChangeError.new("New file #{newFileName} is different from old file #{outFile}: #{diffReport(newFileContents,oldFileContents)}")
        end
      else
        raise UnexpectedChangeError.new("Can't check #{outFile} against backup #{oldFile} " + 
                                        "because backup file doesn't exist")
      end
    end
def checkAndEnsureOutputFileUnchanged(outFile, oldFile)
      if File.exists? oldFile
        oldFileContents = File.read(oldFile)
        newFileContents = File.read(outFile)
        if oldFileContents != newFileContents
          newFileName = outFile + ".new"
          File.rename(outFile, newFileName)
          File.rename(oldFile, outFile)
          raise UnexpectedChangeError.new("New file #{newFileName} is different from old file #{outFile}: #{diffReport(newFileContents,oldFileContents)}")
        end
      else
        raise UnexpectedChangeError.new("Can't check #{outFile} against backup #{oldFile} " + 
                                        "because backup file doesn't exist")
      end
    end
Check that a newly created output file has the same contents as another (backup) file containing the old contents
 If it has changed, actually reset the new file to have ".new" at the end of its name,
 and rename the backup file to be the output file (in effect reverting the newly written output).