I have the following code:
with open(\'current.cfg\', \'r\') as current:
if len(current.read()) == 0:
print(\'FILE IS EMPTY\')
else:
When you do current.read(), you consume the contents of the file, so a subsequent current.readlines() returns an empty list.
Martijn Pieters's code is the way to go.
Alternatively, you could do rewind to the beginning of the file with a current.seek(0) before the readlines(), but this is unnecessarily complicated.