
def first_line(filename):
    try:    
        with open(filename) as f:
            first_line = f.readline()
        return first_line
    except FileNotFoundError:
        return None


file = input("Filnavn: ")
line = first_line(file)

if line is None:
    print("Noe gikk feil!")
else:
    print(f'The first line of {file} is:')
    print(line)
