Writes value to path through AtomicFile, so a crash never leaves a half-written file.
Writes value to output, which is not closed.