Changed to a try-with resources, 'cause... well, to shutup my IDE.  Also, add a useless paranoid check that probably won't ever happen.