diff --git a/lib/ansible/modules/extras/files/blockinfile.py b/lib/ansible/modules/extras/files/blockinfile.py
index 37d89ca2c8..81834dfd2d 100644
--- a/lib/ansible/modules/extras/files/blockinfile.py
+++ b/lib/ansible/modules/extras/files/blockinfile.py
@@ -280,7 +280,9 @@ def main():
     lines[n0:n0] = blocklines
 
     if lines:
-        result = '\n'.join(lines)+'\n'
+        result = '\n'.join(lines)
+        if original.endswith('\n'):
+            result += '\n'
     else:
         result = ''
     if original == result: