   
         
 exports.Tail = Tail
+

  watch: ->
    return if @isWatching
    @isWatching = true
    if fs.watch then @watcher = fs.watch @filename, @fsWatchOptions, (e) => @watchEvent e
    else fs.watchFile @filename, @fsWatchOptions, (curr, prev) => @watchFileEvent curr, prev
  
  watchEvent:  (e) ->
    if e is 'change'
      fs.stat @filename, (err, stats) =>
        @emit 'error', err if err
        if stats.size > @pos
          @queue.push({start: @pos, end: stats.size})
          @internalDispatcher.emit("next") if @queue.length is 1
    else if e is 'rename'
      @unwatch()
      setTimeout (=> @watch()), 1000
  
  watchFileEvent: (curr, prev) ->
    if curr.size > prev.size

      @internalDispatcher.emit("next") if @queue.length is 1
  
  unwatch: ->
    if fs.watch && @watcher
      @watcher.close()
      @pos = 0
    else fs.unwatchFile @filename
