You can do this without an intermediate file variable, and without having to explicitly close like so:
```ruby
x = File.open(path, 'rb') { |f| f.read(f.stat.size) }
```