Modified program to save to file.