Fix buffer bug in token writer

Change-Id: I615618fe7833e1b97ae86b23d1fee760401154db
diff --git a/datok.go b/datok.go
index 48bb757..f19ce5a 100644
--- a/datok.go
+++ b/datok.go
@@ -932,8 +932,12 @@
 				// token and start blank at the root node of the automaton for the remaining data.
 				// It may be beneficial to have something like a "drop()" event to capture these cases,
 				// as they are likely the result of a bad automaton design.
-				if buffc-bufft == 0 {
+				if buffc-bufft <= 0 {
 					buffc++
+					if buffc == 0 {
+						eof = true
+						break
+					}
 				}
 
 				if DEBUG {