
def first_line(filename):
    with open(filename) as f:
        first_line = f.readline()
    return first_line

while True:
    try:
        file = input("Filnavn: ")
        line = first_line(file)
        break
    except FileNotFoundError:
        print("File doesn't exist. Try again")

print(f'The first line of {file} is:')
print(line)
