Fix file corruption on Windows