Refactor of file a tiny bit

Untested, will do shortly, but now writing a new file per dump from buffer.