Python writing general script using open('file', 'r') : I am writing a script where I first read a file using 
`with open('file', 'r') as file`,
do some operation, and then write it to a new file using
`with open(`newfile`, 'w') as newfile`.

My question is, what do I need to change in the script to make it general for a number of files, so that I can just call the script with the file name from the terminal like `python3 script.py file.ext`? Also, is there a way to write the output back into the original file using this method?

Any help is greatly appreciated!