Delete temporary files after they are used

This patch explicitly deletes temporary files after they have been read. This is required as using `deleteOnExit` does not seem to take effect when the JVM created by rJava exits.

cc @zhangyouhua
Hmm -- I always thought Scala auto-inferred the return type based on the last line of the function. Anyways its better style to have explicit return types. Added now