add output file function