How can I create a function that will allow me to edit a .txt file in python?
<p>I'm trying to create a very simple function that will let me edit a file that I've already written using Python 3.5. My writing function works just fine, but I'm including it just in case it matters. It looks like this:</p>

<pre><code>def typer():
    print("")
    print("Start typing to begin.")
    typercommand = input("  ")
    saveAs = input("Save file as: ")
    with open(saveAs, 'w') as f:
        f.write(typercommand)
    if saveAs == (""):
        commandLine()
    commandLine()
</code></pre>

<p>My editing function looks like this:</p>

<pre><code>def edit():
    file = input("Which file do you want to edit? ")
    with open(file, 'a') as f:
        for line in f:
            print(line)
</code></pre>

<p>I then call the function using my command line function like this:</p>

<pre><code>def commandLine():
    command = input("~$: ")
    if command == ("edit"):
        edit()
</code></pre>

<p>I don't get any errors but nothing else happens, either (I'm just redirected to my base command line). And by that I mean that I call the function and then, on the line directly beneath it, it get the prompt for the command line I made for the program (~$). What is wrong with my code and what could I do to remedy it?</p>