added parameter to toggle output_to_file for real time processing