Added filepath separators according to the system properties.
Create the parent directory when writing to a file