import sys scale = 1.5 def transform(): with open(sys.argv[1]) as f: for line in f.readlines(): if "PIC" yield f"" yield "" else: yield line lines = list(transform()) with open(sys.argv[1], 'w') as f: f.write(''.join(lines))