Create dir before writing a file in it.