diff --git a/decoder/src/Producer.cpp b/decoder/src/Producer.cpp
index 711d57de506c922e61962342bcde263529cd7773..b0925ed849c853874dde2131449b4ff16733eee3 100644
--- a/decoder/src/Producer.cpp
+++ b/decoder/src/Producer.cpp
@@ -68,6 +68,9 @@ Producer::Producer(std::filesystem::path input, std::filesystem::path output) :
 // Returns false if we are finished and true if we have events remaining.
 bool Producer::apply(BaseConfig & config)
 {
+  if (not parser.hasNext())
+    return false;
+
   auto text = util::splitAsUtf8(parser.getCurrentNodeText());
   if (text.empty())
     util::error("Trying to add empty text to raw input.");