     process.stdin.on 'data', (chunk) -> fileContents += chunk.toString()
     process.stdin.on 'end', ->
       fileTokens = CSON.parse(fileContents)
-      html = new delexe().renderSync({filePath, fileTokens, scopeName: cli.argv.scope})
-      if outputPath
-        fs.writeFileSync(outputPath, html)
-      else
-        console.log(html)
+      string = delexe.renderSync({filePath, fileTokens, scopeName: cli.argv.scope})
+      output outputPath, string

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

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

fs = require 'fs-plus'
CSON = require 'season'
optimist = require 'optimist'
Delexe = require './delexe'

module.exports = ->
  cli = optimist.describe('h', 'Show this message').alias('h', 'help')
