diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 3394e58fee..b844d76627 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -530,7 +530,8 @@ class Device(DeviceConfig, DevicePlugin): if not os.access(sz, os.R_OK): continue try: - sz = int(open(sz, 'rb').read().decode('utf-8')) + with open(sz, 'rb') as szf: + sz = int(szf.read().decode('utf-8')) except: continue if sz > 0: