Last two logins script

This is the contents of my file:

donald.duck 12/07/2009 12:07:58
donald.duck 12/07/2009 12:17:36
donald.duck 12/07/2009 12:22:29
donald.duck 12/07/2009 12:26:39
donald.duck 12/07/2009 12:28:01
mickey.mouse 12/07/2009 12:48:49
mickey.mouse 12/07/2009 12:49:33
mickey.mouse 12/07/2009 12:50:04

These are log in times/dates. How can I just keep the last two entries for any specific user only? I want the new output file to read:

donald.duck 12/07/2009 12:26:39
donald.duck 12/07/2009 12:28:01
mickey.mouse 12/07/2009 12:49:33
mickey.mouse 12/07/2009 12:50:04

Something like:

for i in $(awk '{print $1}' YOURFILE | sort -u); do grep $i YOURFILE | tail -n2; done

That works great, cabrao! Thanks a million! Just curious on how to have this output redirected back to the original file, if possible. Or will I have to have this output directed to a new file? I don't want the original file to grow out of control, as it is capturing all logins.

Maybe (if you can not redirect new output into original file) we could parse any lines in original file with a date older than 90 days? Any help is appreciated...

---------- Post updated at 10:03 AM ---------- Previous update was at 09:41 AM ----------

This is the original script to produce output file:

grep somestring /var/log/messages | awk '{print $1, $2, $9}' | sed -e 's/account=//g' -e 's/@gmail.com//g' -e 's/;//g' -e 's/,...//g' | tr '-' ' '|awk '{print $5" "$2"/"$3"/"$1" "$4}' | sort -o /tmp/testfile1 | uniq

Is there a way to add what cabrao stated to this to minimize the size of my current forever-growing output file (/tmp/testfile1)? All help is greatly appreciated.

Try:

awk '{ A[$1]=_p"\n"$0;_p=$0; } END { for ( e in A) print A[e] }' file