Bugfix: create directory before creating files