     fileContents = ''
     process.stdin.on 'data', (chunk) -> fileContents += chunk.toString()
     process.stdin.on 'end', ->
-      tokens = new Textlex().lexSync({filePath, fileContents, scopeName: cli.argv.scope})
-      if outputPath
-        fs.writeFileSync(outputPath, JSON.stringify tokens, null, cli.argv.t)
-      else
-        console.log(JSON.stringify tokens, null, cli.argv.t)
+      tokens = textlex.lexSync({filePath, fileContents, scopeName: cli.argv.scope})
+      output outputPath, tokens, cli.argv.tab

  outputPath = cli.argv.output
  outputPath = path.resolve(outputPath) if outputPath

  if filePath
    filePath = path.resolve(filePath)
    unless fs.isFileSync(filePath)

      process.exit(1)
      return

    tokens = textlex.lexSync({filePath, scopeName: cli.argv.scope})
    output outputPath, tokens, cli.argv.tab
  else
    filePath = cli.argv.f
    process.stdin.resume()
