Bugfix when dumping just headers without a summary

...g was used without summary. The if condition assumed that there would be something to write, but fwrite returns 0 when it writes nothing and when an error occurs. Adding a check of the count to write solves the problem.