Flushing to file to force writing of header and before closing. This cau...

...ses enough latency to avoid the duplicate header entry. Fix for #297