diff --git a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp
index f2cae210d2ddcd1f43ad2b63288d80139658bb60..aa2150ba23ac1373cda9486b942754ea12479275 100644
--- a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp
+++ b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp
@@ -73,8 +73,8 @@ MeshLib::NodePartitionedMesh* NodePartitionedMeshReader::read(
     MeshLib::NodePartitionedMesh* mesh = nullptr;
 
     /// Prefix of the filename of the partitioned mesh files.
-    std::string filename_prefix = file_name_base;
-    boost::erase_last(filename_prefix, ".vtk");
+    std::string const filename_prefix =
+        boost::erase_last_copy(file_name_base, ".vtk");
 
     // Always try binary file first
     std::string const fname_new = filename_prefix + "_partitioned_msh_cfg" +