diff --git a/lisp/org-src.el b/lisp/org-src.el
index b4d4c04..75db1d7 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -690,7 +690,7 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
     (goto-char beg)
     (when allow-write-back-p
       (delete-region beg (max beg (1- end)))
-      (unless (string-match "^[ \t]*$" code)
+      (unless (string-match "\\`[ \t]*\\'" code)
 	(insert code)
 	(delete-char 1))
       (goto-char beg)
