00e55dd223
Backport #15456 This PR simply checks the status before writing the header. Signed-off-by: Andrew Thornton <art27@cantab.net>