Fix various writer bugs exposed by using 'changeOutputFile'
Exporter plugin: fix writing to multiple files

Fixes #10635.
FormatWriter: close the output file before reinitializing
Merge pull request #470 from melissalinkert/multi-file-export

Fix export of multiple files