diff --git a/src/plugins/cppeditor/cppinsertdecldef.cpp b/src/plugins/cppeditor/cppinsertdecldef.cpp
index 636a388b6fd15664646602d761fe1c40d8bc3f48..b9b14e3b1d884fdd030ef4dcef8437faa343e156 100644
--- a/src/plugins/cppeditor/cppinsertdecldef.cpp
+++ b/src/plugins/cppeditor/cppinsertdecldef.cpp
@@ -567,7 +567,7 @@ public:
             CppRefactoringChanges implRefactoring(snapshot());
             CppRefactoringFilePtr implFile = implRefactoring.file(implFileName);
             ChangeSet implChanges;
-            const int implInsertPos = QFileInfo(implFileName).size();
+            const int implInsertPos = implFile->document()->characterCount() - 1;
             implChanges.insert(implInsertPos, implementation);
             implFile->setChangeSet(implChanges);
             implFile->appendIndentRange(