Convert write insert and footer to use streams.

See #356.
See #355.
See #107.
See #4.
Write delete now writes footer separately.

See #356.
See #355.
See #107.
See #4.