capture_file closing early fixed.
In-progress: writing.
minor fixes.