     (goto-char (point-max))
     (newline)
     (forward-char -1))
-  (duplicate-region num (point-at-bol) (1+ (point-at-eol)))
-  (goto-char (1- (point))))
+  (duplicate-region num (point-at-bol) (1+ (point-at-eol))))
 
 (defun yank-indented ()
   (interactive)

  "Duplicates the current line or region ARG times.
If there's no region, the current line will be duplicated."
  (interactive "p")
  (if (region-active-p)
      (duplicate-region arg)
    (duplicate-current-line arg)))

(defun duplicate-region (num &optional start end)
  "Duplicates the region bounded by START and END NUM times.

         (end (or end (region-end)))
         (region (buffer-substring start end)))
    (kill-ring-save start end)
    (goto-char start)
    (dotimes (i num)
      (insert region))))

