You forgot to call the close function here :)
This is essentially pointing the code to the object, but not doing anything with it. You'll need those parentheses to actually free up the file's resources.
You'll also want to close emptyfile below, and outfile in the choice == "1" block above