         startIndex = history.length - historySize
         history = history.reverse().splice(startIndex, historySize)
 
-        outstream = fs.createWriteStream('.hubot_history')
+        outstream = fs.createWriteStream(historyPath)
         # >= node 0.10
         outstream.on 'finish', () =>
           @shutdown()

         @shutdown()

  loadHistory: (callback) ->
    fs.exists '.hubot_history', (exists) ->
      if exists
        instream = fs.createReadStream('.hubot_history')
        outstream = new stream
        outstream.readable = true
        outstream.writable = true


    @cli.on 'history', (item) =>
      if item.length > 0 and item isnt 'exit' and item isnt 'history'
        fs.appendFile historyPath, "#{item}\n", (err) =>
          @robot.emit 'error', err if err

    @cli.on 'close', () =>
