diff --git a/lib/subprocess.rb b/lib/subprocess.rb
index <HASH>..<HASH> 100644
--- a/lib/subprocess.rb
+++ b/lib/subprocess.rb
@@ -499,7 +499,7 @@ module Subprocess
               @stdin.close
               wait_w.delete(@stdin)
             end
-            input[0...written] = ''
+            input = input[written..input.length]
             if input.empty?
               @stdin.close
               wait_w.delete(@stdin)
Make Process#communicate do less work on every iteration (#<I>)

* Make Process#communicate do less work on every iteration