modified the file save code to make retrival of the last value more efficient