 
           fs.writeFile path, newStats + '\n' + restOfFile, (err) ->
             if err
-              cli.error err
+              logger.error err
       else
-        cli.error err
+        logger.error err
 
   cdata = (str) ->
     return '<![CDATA[' + str + ']]>'
 
   appendLine = (path, line) ->
-    fs.appendFileSync(path, line + "\n")
+    fs.appendFile path, line + "\n", (err) ->
+      throw err if err
 
   toTag = (name, attrs, close, content) ->
     end = (if close then "/>" else ">")

  sanitizedPath: (path) =>
    filePath = process.cwd() + "/report.xml" unless path?
    if fs.existsSync(filePath)
      cli.info "File exists at #{filePath}, deleting..."
      fs.unlinkSync(filePath)
    filePath


fs = require 'fs'
logger = require './../logger'
htmlencode = require 'htmlencode'

class XUnitReporter
