   # (a b "c" '(d r)) => [a, b, "c", [d, r]]
   takeList: (string) ->
     tokens = []
-
     # drop "("
     string = @tail string
 
-    while (string[0] isnt ')')
+    while (string[0] isnt ')' and string.length isnt 0)
       switch @head string
         when ' '
           string = @tail string


    return [token, rest]

module.exports = ParseSExpr

{Transform} = require 'stream'



class ParseSExpr extends Transform

