Added option to delete or keep temporary file