title: How can I fix this: ValueError invalid literal for int() with base 10: ''? Python
body: <pre><code>import os
  txt_file = 'highscore.txt'
  score = total_points
  
  if not os.path.exists(txt_file):
      with open(txt_file, 'w') as f:
          f.write('Score: {score}\n'
                  + 'Name: {name}')
  
  with open(txt_file, 'r') as f:
      previous_score = int(f.readline().split()[-1])
  
  # compare the previous score with current score and write the highest score
  if previous_score &lt; score:
      with open(txt_file, 'w') as f:
          f.write(f'Score: {score}\n'
                  + f'Name: {name}')
  </code></pre>
  
  <p>I understand that because I have <code>Score:</code> on the line, it isn't coming back as just the score. If I use <code>re.findall</code> I can get just the score but it turns into a list, and I still can't use <code>int(previous_score) &lt; int(score)</code>. How do I go about making this work?</p>
  
  <p>Thank you to the previous commenter, Sachin, who helped me get this far by the way.</p>
  
  <p>edit:
  I managed to get it with all of your help. Thank you so much!</p>