adding output file handling