Python file overwriting script
First of all, you should definitely switch to using with context manager which is gonna safely and automatically close the opened file handler.

Also, you need to improve your variable names, l1, l2, l3 or z are not descriptive.

And, you may use .writelines() to write a list of strings each of them on a separate line.

In the end, you might get something along these lines:

print("Type the name of the file for overwriting.")
file_name = input("&gt;")

with open(file_name) as input_file:
    print("The contents are currently: \n", input_file.read())
    print("Enter in the new lines")

lines = [input("&gt;") for _ in range(3)]

print("Entering new lines.")
with open(file_name, 'w') as output_file:
    output_file.writelines(lines)

with open(file_name) as input_file:
    print("The new contents are:")
    print(input_file.read())