This looks like a logging file, write out keynames and their values over time..
Which means this, one most likely already knows the key names that will be in there to start with and taking that into account, you can scan backwards from the list getting the last one that was entered.
However, if the key names are not known, then one will need to scan the list starting at the beginning, read a key in , check to see if its in key list yet that is being built, if so then don't bother and move on. If it's not yet in the list then add it to this side list and then call the function like laid out to get the last one on the list..
I am getting a feeling this is a home work assignment so this means the key names are not known to start with. If that being the case a forward read is needed to ensure you have all the unknown keys before you decide on duplicates.
Yup, looks like home work!
I am done.