use unique_ptr instead of raw pointer

The destructor of `file_h` should take care of closing the underlying file on its own.