fixed bug when using file output