It's even easier

Try
the_text = File.read("somefile.txt")
Sammy Larbi wrote:
> I know opening a file and passing a block will execute the block in context
> of the file and then close the file.
>
> Example:
>
> File.open("somefile.txt") {|f| the_text = f.read }
>
> After running, somefile.txt will be closed.
>
> I'm wondering if it's ok to read a file like this:
>
> the_text = File.open("somefile.txt").read
>
> Will that close automatically? If not, how would I go about closing it?
>
> Thanks,
> Sam
>
>