    @listen 'saveAs', -> IPC.send 'saveFile'
    @listen 'saveFile', (e, file) ->
     return if not file?
-    @file =
-     name: PATH.basename file, '.ds'
-     path: file
+    @options.file = file
+    @setFile()
+
     @content = @removeTrailingSpace @editor.getText()
     @editor.setText @content
     @_editorChanged = true
     @on.saveTemporary()
-    @options.file = @file.path
     @saveOptions()
     @elems.save.style.display = 'inline-block'
     @elems.saveName.textContent = "#{@file.name}"
+    FS.writeFile @file.path, @content, (err) ->
+     if err?
+      console.error err
+     else
+      console.log 'file saved'
+
 
    @listen 'print', ->
     @editor.on.print()

   @listen 'fileOpened', (e, files) ->
    return if not files?
    return if files.length <= 0
    file = files[0]
    @file =
     name: PATH.basename file, '.ds'
     path: file
    @content = "#{FS.readFileSync file}"
    @editor.setText @content
    @_editorChanged = true
    @on.saveTemporary()
    @options.file = @file.path
    @saveOptions()
    @elems.save.style.display = 'inline-block'
    @elems.saveName.textContent = "#{@file.name}"

    @editor.render @elems.editor, @elems.editorToolbar, =>
     @_watchInterval = setInterval @on.watchChanges, CHANGED_WATCH_INTERVAL
     @_saveTemInterval = setInterval @on.saveTemporary, TEMPORARY_SAVE_INTERVAL
     @editor.setText @_tempContent
     delete @_tempContent
     if @file?
      @elems.save.style.display = 'inline-block'
     @on.watchChanges()
     callback()

   @listen 'folder', -> IPC.send 'openFolder'
