diff --git a/versionstamping/versionstamper.py b/versionstamping/versionstamper.py index d953aa4..da01aa2 100644 --- a/versionstamping/versionstamper.py +++ b/versionstamping/versionstamper.py @@ -28,12 +28,13 @@ def main(argv): with open(filetoconvert, 'x') as f: 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) + fileread = c.read() + c.close() + print("Detected %s instances of %s pre-conversion"%(fileread.count(pattern),pattern)) + converted = fileread.replace(pattern, substitute) print ("DEBUG: %s "%converted) print("Confirmed %s instances of %s post-conversion"%(converted.count(substitute),substitute)) f.write(converted) - c.close() f.close() return 0