file output almost working