Refactoring extraction to implicitly close

The previous implementation was naive in that it would leave the temp
file either open or still linked to the file system if an exception
were encountered.

http://ruby-doc.org/stdlib-2.0.0/libdoc/tempfile/rdoc/Tempfile.html#open-method