Using collectionFS to write to a file

hello! hope you can help!

on the client side, i have an upload button to insert a file in the FS.Collection 'files’
but before saving that file, i want to write to the file then save it.
i thought you use transformWrite…? but the following code gives an error: Object #Object> has no method ‘on’

any help would be appreciated! thank you!

  if (Meteor.isServer) {
        Files = new FS.Collection('files', {
            stores: [new FS.Store.FileSystem("files"),
                {transformWrite: writeUserName}
        var writeUserName = function(fileObj, readStream, writeStream) {