Fix buffer rewind at end of transmission

Change-Id: I5abb90153931574acf0df5e95e5b286c883539e5
diff --git a/matrix.go b/matrix.go
index 2ac31c3..3a06951 100644
--- a/matrix.go
+++ b/matrix.go
@@ -503,6 +503,16 @@
 			}
 		}
 
+		if eot {
+			eot = false
+			textEnd = true
+			w.TextEnd(buffc)
+			rewindBuffer = true
+			if DEBUG {
+				fmt.Println("END OF TEXT")
+			}
+		}
+
 		// Rewind the buffer if necessary
 		if rewindBuffer {
 
@@ -528,14 +538,6 @@
 			}
 		}
 
-		if eot {
-			eot = false
-			textEnd = true
-			w.TextEnd(buffc)
-			if DEBUG {
-				fmt.Println("END OF TEXT")
-			}
-		}
 		t &= ^FIRSTBIT
 
 		newchar = true