title: IndexError: list index out of range - Can't get my txt file to save the output in Python
body: <p>I'm writing a program that is referring to two text files. One stores the list of currencies in a sentence and one stores the current value. I want it to only store the value of the currency in the sentence once, but then stores each order so it can be replaced on screen. E.g. Sterling, Euro (in one file). 1,1,2 (in the order file). I keep getting the error message 
  IndexError: list index out of range</p>
  
  <pre><code>all_currency = []
  value_of_currency = []
  
  my_words_file = open("words.txt","r")
  my_words_document = my_words_file.readline()
  while my_words_document != "": 
          all_currency.append(my_words_document.strip())
          my_words_document = my_words_file.readline()
  print("output of the words in the saved list:",str(all_currency))
  my_words_file.close()
  positions = ""
  my_numbers_file = open("numbers.txt","r")
  value_of_currency = my_numbers_file.readline().strip().split()
  my_numbers_file.close()
  for mynumbers in value_of_currency:
      positions += all_currency[int(mynumbers)]+" "
  
  print("output of the positions in the saved list:",positions)
  </code></pre>