```coffeescript
fs = require 'fs'
noflo = require '../../lib/NoFlo'

class WriteFile extends noflo.Component
  constructor: ->
    @data = null
    @filename = null

    @inPorts =
      in: new noflo.Port
      filename: new noflo.Port
    @outPorts =
      out: new noflo.Port
      error: new noflo.Port

    @inPorts.in.on 'data', (data) =>
      @data = data
      @writeFile @filename, data if @filename

    @inPorts.filename.on 'data', (data) =>
      @filename = data
      @writeFile data, @data if @data

    @inPorts.filename.on 'endgroup', =>
      @filename = null

  writeFile: (filename, data) ->
    fs.writeFile filename, data, 'utf-8', (err) =>
      return @outPorts.error send err if err
      @outPorts.out.send filename
      @outPorts.out.disconnect()

exports.getComponent = -> new WriteFile
```

Write files when you have both name and content
user
```coffeescript
fs = require 'fs'
noflo = require '../../lib/NoFlo'

class WriteFile extends noflo.Component
  constructor: ->
    @data = null
    @filename = null

    @inPorts =
      in: new noflo.Port
      filename: new noflo.Port
    @outPorts =
      out: new noflo.Port
      error: new noflo.Port

    @inPorts.in.on 'data', (data) =>
      if @filename
        @writeFile @filename, data
        @filename = null
        return
      @data = data

    @inPorts.filename.on 'data', (data) =>
      if @data
        @writeFile data, @data
        @data = null
        return
      @filename = data

  writeFile: (filename, data) ->
    fs.writeFile filename, data, 'utf-8', (err) =>
      return @outPorts.error.send err if err
      @outPorts.out.send filename
      @outPorts.out.disconnect()

exports.getComponent = -> new WriteFile
```
assistant