Merge pull request #6 from doriath/fix-infinite-loop-bug

Fix a bug that causes infinite loop.
diff --git a/quote.go b/quote.go
index 9842d5e..72a8cb3 100644
--- a/quote.go
+++ b/quote.go
@@ -84,8 +84,8 @@
 				inQuote = true
 			}
 			buf.WriteString(word[0:i])
-			word = word[i+1:]
 		}
+		word = word[i+1:]
 		if inQuote {
 			buf.WriteByte('\'')
 			inQuote = false
diff --git a/quote_test.go b/quote_test.go
index 0368870..535ed5c 100644
--- a/quote_test.go
+++ b/quote_test.go
@@ -27,4 +27,5 @@
 	{[]string{"one", "", "three"}, "one '' three"},
 	{[]string{"some(parentheses)"}, "some\\(parentheses\\)"},
 	{[]string{"$some_ot~her_)spe!cial_*_characters"}, "\\$some_ot~her_\\)spe\\!cial_\\*_characters"},
+	{[]string{"' "}, "\\'' '"},
 }