Sorry, forgot to mention. Please just put one ``if not leaveOpen:`` around all of this code instead of multiple of these ifs.