title: How do I overwrite a file with the fs module?
body: <p>I'm making an electron app for windows. When I try to overwrite a txt file it just deletes everything. I want that but the content I am trying to put is not writing to the file.
  Here is the code for when receive a prompt to save:</p>
  
  <pre><code>ipcRenderer.on('saveFile', function(){
          console.log(fileData.path)
          fs.writeFile(fileData.path, editor.innerText, 'utf8', (err) =&gt; {
              if(err) throw err;
              console.log('File Saved')
          })
      })
  </code></pre>
  
  <p>Here is the code when I send the file data (file path, text in file, etc.):</p>
  
  <pre><code>fileBtn.addEventListener('change', function(e){
          if(fileBtn.files[0].type.substring(0, 4) == 'text'){
              file.ext = fileBtn.files[0].name.substr(fileBtn.files[0].name.indexOf('.'))
              console.log(fileBtn.files[0])
              file.path = fileBtn.files[0].path
              file.text = fs.readFileSync(file.path, 'utf8');
              ipcRenderer.send('newFile', file)
          }else{
              console.error('Not a valid file type')
              return;
          }
  
      })
  </code></pre>