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 #485 from melissalinkert/rebased/develop/multi-file-export

Fix export of multiple files (rebased onto develop)