Adjusted saving to a file using wirter. All results will be saved to a file rather that displayed. It is for debugging.