'''
Open up the file hello.txt and do something with it.
'''

'''
(1) open the file.
(2) read from it.
(3) close it.
'''

# print it...
def print_file():
  f = open('hello.txt')
  s = f.read()
  print(s)
  f.close()

#print_file()

def print_lines(filename):
  try:
    f = open(filename)
    lines = f.readlines()
    #print(lines)
    count = 1
    for line in lines:
      print(f'{count}: {line}', end='')
      count += 1
  except FileNotFoundError:
    print('File does not exist.')

#print_lines('hello.txt')

def save_file(filename, value):
  f = open(filename, 'w')
  f.write(value)
  f.close()

#save_file('newfile.txt', 'hello blah blah')
#save_file('newfile.txt', str([1, 2, 3]))
save_file('username.txt', 'jkinne')
save_file('password.txt', 'lkasjdflkj')

'''
high_score.txt
652345
'''
def save_high_score(x):
  save_file('high_score.txt', str(x))
save_high_score(1000)

def get_high_score():
  f = open('high_score.txt')
  x = int(f.read())
  f.close()
  return x
print('high score is', get_high_score())
