Better file output timing logic