diff --git a/lib/applescript.js b/lib/applescript.js
index <HASH>..<HASH> 100644
--- a/lib/applescript.js
+++ b/lib/applescript.js
@@ -21,19 +21,19 @@ exports.execString = function execString(str, callback) {
 
 
 function runApplescript(strOrPath, args, callback) {
-  var needsE = false;
+  var isString = false;
   if (!Array.isArray(args)) {
     callback = args;
     args = [];
-    needsE = true;
+    isString = true;
   }
   
   // args get added in reverse order with 'unshift'
-  args.unshift(strOrPath);
-  if (needsE) {
-    args.unshift("-e"); // If 'execString' was called
-  }
   args.unshift("-ss"); // To output machine-readable text.
+  if (!isString) {
+    // The name of the file is the final arg if 'execFile' was called.
+    args.unshift(strOrPath);
+  }
   
   var interpreter = spawn(exports.osascript, args);
   
@@ -52,6 +52,11 @@ function runApplescript(strOrPath, args, callback) {
     callback(code, result, stderr);
   });
   
+  if (isString) {
+    // Write the given applescript String to stdin if 'execString' was called.
+    interpreter.stdin.write(strOrPath);
+    interpreter.stdin.end();
+  }
 }
 
 function processOutput(stdout) {
Write to stdin when 'execString' is called, instead of passing the String as an argument (potentially dangerous).