close the files after we have read/written them. explicily open copy file for reading

This commit is contained in:
georgelinsdell 2017-12-20 15:51:45 +00:00
commit 1124ca5cd6

View file

@ -27,11 +27,13 @@ def main(argv):
return 1
with open(filetoconvert, 'x') as f:
with open(filecopy) as c:
with open(filecopy,'r') as c:
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"%(converted.count(substitute),substitute))
f.write(converted)
c.close()
f.close()
return 0