The fix from #2 not has solved all problems. After several weeks of operation the file creation fails from time to time or seems get's out of sync. The part where data is written to file might need a complete rewrite with less async "triggering".