Throw exception if file cannot be opened.