title: Swift 3 Write String to binary file
body: <p>How can I write a string to a binary file?
  I have tried a lot,  but every time my file appear as a plain text file..</p>
  
  <p>I am not interested in a plist file..</p>
  
  <pre><code>            string = String(data: data, encoding: String.Encoding.utf8)!;
              var buffer = [UInt8](string.utf8);
  
              var f = fopen("newdata.dat", "w");
              let success = fwrite(buffer, MemoryLayout&lt;UInt8&gt;.size, buffer.count, f);
              fsync(fileno(f));
              fclose(f);
              print("success: \(success)");
  </code></pre>