Make sure the file closes if there is a DuplicateGemFound error raised