Fixed operation on Mac OS X

Thought this was a cool capability, but did not work for me on Mac OS X (10.8.4). No matter what I typed into the editor, the function always returned no data. This patch fixes the problem, at the cost of a few additional low-level operations (closing the temporary file before the editor is invoked, then reopening, then manually deleting).