diff --git a/transition_machine/include/Config.hpp b/transition_machine/include/Config.hpp
index bf7327af0b5a1dc54d72f12d076fa96c4bf4e161..88ed7f7d24dd70890fb603d542b0fd39895e5fef 100644
--- a/transition_machine/include/Config.hpp
+++ b/transition_machine/include/Config.hpp
@@ -157,6 +157,8 @@ class Config
   private :
 
   const unsigned int HISTORY_SIZE = 2000;
+  /// @brief True if eos tape have been modified by an action.
+  bool eosTouched;
   /// @brief The name of the current state of the TransitionMachine.
   std::string currentStateName;
   /// @brief For each state of the TransitionMachine, an history of the Action that have been applied to this Config.
@@ -362,6 +364,8 @@ class Config
   ///
   /// @return The head of the multi-tapes buffer.
   int getHead() const;
+  /// @brief set eosTouched to true.
+  void setEosTouched();
   /// @brief Return true if the head is at the end of the tapes.
   ///
   /// @return True if the head is at the end of the tapes.
diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp
index b8affab8ec818584431de065b468c9b99a5fb01f..6977f3ac5af42839b5f0d7f76fad623fc445a4dc 100644
--- a/transition_machine/src/ActionBank.cpp
+++ b/transition_machine/src/ActionBank.cpp
@@ -685,6 +685,7 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
           int b0 = c.getHead();
           int s0 = c.stackTop();
           simpleBufferWrite(c, ProgramParameters::sequenceDelimiterTape, ProgramParameters::sequenceDelimiter, s0-b0);
+          c.setEosTouched();
         };
       auto undo = [](Config & c, Action::BasicAction)
         {
diff --git a/transition_machine/src/Config.cpp b/transition_machine/src/Config.cpp
index 254da76897d6bca4d9183bde37d8695b67e68fa4..63f1c0c65d9f8acc0bd352eeba856e2443507c53 100644
--- a/transition_machine/src/Config.cpp
+++ b/transition_machine/src/Config.cpp
@@ -16,6 +16,7 @@
 Config::Config(BD & bd, const std::string inputFilename) : bd(bd), hashHistory(HISTORY_SIZE), pastActions(HISTORY_SIZE)
 {
   this->outputFile = nullptr;
+  this->eosTouched = false;
   this->stackHistory = -1;
   this->lastIndexPrinted = -1;
   this->inputFilename = inputFilename;
@@ -39,6 +40,7 @@ Config::Config(const Config & other) : bd(other.bd), hashHistory(other.hashHisto
   this->stackHistory = other.stackHistory;
   this->head = other.head;
   this->outputFile = other.outputFile;
+  this->eosTouched = other.eosTouched;
   this->lastIndexPrinted = other.lastIndexPrinted;
   this->tapes = other.tapes;
   this->totalEntropy = other.totalEntropy;
@@ -94,8 +96,6 @@ void Config::readInput()
       tape.addToHyp("");
     }
 
-    fprintf(stderr, "rawInputHeadIndex=%d rawInputSize=%lu\n", rawInputHeadIndex, rawInput.size());
-
     return;
   }
 
@@ -395,7 +395,7 @@ void Config::printAsOutput(FILE * output, int dataIndex, int realIndex, bool for
     }
     else
     {
-      if (eos.getKnown())
+      if (eos.getKnown() && !eosTouched)
         eosStr = eos.getRef(dataIndex-head);
       else
         eosStr = eos.getHyp(dataIndex-head);
@@ -494,6 +494,7 @@ void Config::reset()
   stackHistory = -1;
 
   head = 0;
+  eosTouched = false;
   rawInputHead = 0;
   rawInputHeadIndex = 0;
   currentWordIndex = 1;
@@ -985,3 +986,8 @@ void Config::updateIdsInSequence()
     fprintf(stderr, "Done updating IDS.\n");
 }
 
+void Config::setEosTouched()
+{
+  eosTouched = true;
+}
+