diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RCompression.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RCompression.java
index 1f3cf0a6fbde35e8978715ce95943e3e423c02ee..92868ceba0918ea765bb21c11bfb4412b5f1c061 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RCompression.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RCompression.java
@@ -259,12 +259,15 @@ public class RCompression {
         Process p = pb.start();
         // version is written to the error output stream
         InputStream is = p.getErrorStream();
+        OutputStream os = p.getOutputStream();
         ProcessOutputManager.OutputThreadVariable readThread = new ProcessOutputManager.OutputThreadVariable(command[0], is);
         readThread.start();
+        os.close();
         try {
             rc = p.waitFor();
             if (rc == 0) {
-                String output = new String(readThread.getData());
+                readThread.join();
+                String output = new String(readThread.getData(), 0, readThread.getTotalRead());
                 String version = "Version ";
                 String firstLine = output.split("\\n")[0];
                 int versionIdx = firstLine.indexOf(version);