close the files after we have read/written them. explicily open copy file for reading
This commit is contained in:
parent
58feb96120
commit
1124ca5cd6
1 changed files with 3 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue