   # Before returning the token stream, run it through the [Rewriter](rewriter.html)
   # unless explicitly asked not to.
   tokenize: (code, options) ->
-    code     = code.replace /(\r|\s+$)/g, ''
+    code     = code.replace(/\r/g, '').replace /\s+$/, ''
     o        = options or {}
     @code    = code         # The remainder of the source code.
     @i       = 0            # Current character position we're parsing.

    indent = options.indent
    return doc if options.herecomment and not include doc, '\n'
    unless options.herecomment
      while (match = HEREDOC_INDENT.exec(doc)) isnt null
        attempt = if match[2]? then match[2] else match[3]
        indent = attempt if not indent? or 0 < attempt.length < indent.length
    indent or= ''
    doc = doc.replace(new RegExp("^" + indent, 'gm'), '')

  # Keeps track of the level of indentation, because a single outdent token
  # can close multiple indents, so we need to know how far in we happen to be.
  lineToken: ->
    return false unless indent = @match MULTI_DENT
    @line += count indent, '\n'
    @i    += indent.length
    prev = @prev 2
    size = indent.length - 1 - indent.lastIndexOf '\n'
    nextCharacter = @match NEXT_CHARACTER, 1
    noNewlines = nextCharacter is '.' or nextCharacter is ',' or @unfinished()
    if size - @indebt is @indent
