FormatWriter: close the output file before reinitializing