Close file opened in load_patch() on success

Fixes #327