Replace (end-of-buffer) with (goto-char (point-max))