using with to open files to avoid ResourceWarning