h = file_open(path)
data = file_read(h)
file_close(h)
return data
is the code you want to read. This essentially is: return file_open(path).success(h -> h, file_read(h)).success(h, data -> file_close(h); data)
A language with thoughtful error handling primitives will support such code.