download: Extract mkdir/write file into function
download: Extract mkdir/write file into function

This prepares this functionality for reuse, which will happen soon.
Tested by ensuring that submissions with directory structures can still
be downloaded.

exercism/cli,exercism/cli,neslom/cli,neslom/cli,neslom/cli