with open('/home/andymccall/development/oxygen/docs/xenon_spec.md', 'r') as f: text = f.read() text = text.replace(' "media_type": text\n}\n ],', ' "media_type": text\n }\n ],') text = text.replace(' signer_roles: [ "official-worker" ]\n}\n ]\n}', ' signer_roles: [ "official-worker" ]\n }\n ]\n}') with open('/home/andymccall/development/oxygen/docs/xenon_spec.md', 'w') as f: f.write(text)