Read the file before attempting to count instances within it.

This commit is contained in:
georgelinsdell 2017-12-20 15:37:44 +00:00
commit 35cbc075a3

View file

@ -28,7 +28,7 @@ def main(argv):
with open(filetoconvert, 'x') as f:
with open(filecopy) as c:
print("Detected %s instances of %s pre-conversion"%(c.count(pattern),pattern))
print("Detected %s instances of %s pre-conversion"%(c.read().count(pattern),pattern))
converted = c.read().replace(pattern, substitute)
print("Confirmed %s instances of %s post-conversion"%s(converted.count(substitute),substitute))
f.write(converted)