Adding function to save the result into a file.