write: only write the footer on close, not on every write

Signed-off-by: David Scott <dave.scott@eu.citrix.com>