Fix exceptional resource leak CID18207
Fix exceptional resource leak CID18215
Fix exceptional resource leak CID60737
Fix exceptional resource leak CID18221
Add a method to retry opening a file

Also fix exceptional resource leak CID18222
Refactor the utility method to download a string

Also fix exceptional resource leak CID18224