[fix #24] Really write file to disk

The map function on managed resources doesn't do what we hoped it does.
I should have better RTFM before writing this code. What we intend here
is `foreach`, which is now the case, and it really flushes to disk.
I also added a flush after writing, this should be handled in the close,
handled itself by the ARM library, but I think it is better to be
explicit here.

fixes #24