in reply to finding next key in db_file

Your choice of labels is very confusing. The opposite of "Next" is "Previous". "Last" is the opposite of "First".