Initialize the correct variable
Don't output anything before successful export

Currently when exporting over HTTP, if an error occurs mid-way we will
halt export, after we already had output some headers and part of the
export.

This makes for a louse user experience, so here we accumulate the export
and only output it if nothing stopped the execution.

Props @dllh: http://core.trac.wordpress.org/ticket/22435#comment:33