Fix file writer issues