beginning-of-buffer should not be used from lisp programs

(goto-char (point-min)) is the suggested replacement by the doc.
Don't assign to free variable save-point

The proper way to do this would be defvar or let, but it is more
sensible to drop the feature completely: replace-match will shift the
point and the saved-point will be invalid. More careful coding could
avoid this, but seems overkill.
Replace setq with let or inlining