another sed solution is to always append it on the last line and delete a pre existing one.
sed -e '$a\' -e '<your-entry>' -e "/<your-entry-properly-escaped>/d"
"properly-escaped" means to put a regex that matches your entry, i.e. to escape all regex controlls from your actuall entry, i.e. to put a backslash infront of ^$/*?+().
this might fail on the last line of your file or if there's no tangling newline, I'm not sure, but that could be dealed with by some nifty branching...