This code reads the file, sorts the lines and writes it back to the file system, without any lib (not even standard lib except the built-in functions). The other answers don't output the results or use any libs for output (pathlib, etc.), or they only print it to the command line.
input_file = "input.txt"
output_file = "output.txt"
with open(input_file) as f:
with open(output_file, "w") as o:
o.write("\n".join(sorted(f.read().splitlines())))
You can also put this inside a function if you have to rename multiple files:
def sort_file(input_file, output_file):
with open(input_file) as f:
with open(output_file, "w") as o:
o.write("\n".join(sorted(f.read().splitlines())))
sort_file("input.txt", "output.txt")