updated for use with pickle, added write to file at program termination