An exception safe file handle for MATLAB