Bugfix mkdir sync

Uses ``sync`` functions to create the folder structure & writing the file.

Closes #9