Emptying the headerfile before writing into it. This prevents defining/undefining a macro multiple times. addresses #3765.