fixed file output bug