consolidate the remove and rename handler code
extract openLogFile to avoid some duplication