--- 
+++ 
@@ -16,7 +16,7 @@
                     }
                     break;
             }
-            if (lineLength > 0) {
+            if (lineLength > 0 && pos > 0) {
                 System.arraycopy(lineSeparator, 0, buf, pos, lineSeparator.length);
                 pos += lineSeparator.length;
             }