diff --git a/src/caosadvancedtools/utils.py b/src/caosadvancedtools/utils.py
index b86c32a27281cb4f6ea1b58f907ab86b940ee292..1a8eaf98a097007d2d908f52c69e572c4a5d5519 100644
--- a/src/caosadvancedtools/utils.py
+++ b/src/caosadvancedtools/utils.py
@@ -26,7 +26,13 @@ import os
 
 
 def replace_path_prefix(path, old_prefix, new_prefix):
-    assert path.startswith(old_prefix)
+    """
+    Replaces the prefix old_prefix in path with new_prefix.
+
+    Raises a RuntimeError when the path does not start with old_prefix.
+    """
+    if not path.startswith(old_prefix):
+        raise RuntimeError("Path does not start with old_prefix")
     path = path[len(old_prefix):]
 
     return os.path.join(new_prefix, path)