Fix file output, threads are broken