Fixed file output issues