title: How to separate string with lines in python?
body: <p>I have a program which spell-checks the input words from a text file and then adds asterisks around the words with typos. The input is like this:</p>
  <pre><code>The quick brown fox
  
  jumps over the lazy dog
  
  and mispells someting
  </code></pre>
  <p>However, the print in the end looks like this:</p>
  <pre><code>*The* quick brown fox jumps over the lazy dog and *mispells* *someting*
  </code></pre>
  <p>How can I add the &quot;\n&quot; in the right places? The code is here:</p>
  <pre><code>def main():
      lahtotiedosto = open(&quot;words.txt&quot;, &quot;r&quot;)
      list = []
      input_list = []
      for rivi in lahtotiedosto:
          rivi = rivi.rstrip()
          list.append(rivi)
  
      print(&quot;Enter the text to be spell-checked (empty line to end input).&quot;)
      typos = 0
      syote = input()
      while syote != &quot;&quot;:
          input_list.append(syote)
          syote = input()
      new_list = []
      for syote in input_list:
          sanat = syote.split(&quot; &quot;)
          for i in sanat:
              if i in list:
                  uusi_lista.append(i)
              else:
                  i = &quot;*{:}*&quot;.format(i)
                  new_list.append(i)
                  typos += 1
  
      print(&quot;Checked text, typos highlighted with '*'&quot;)
      ready_list = ' '.join(new_list)
      print(ready_list)
      print(&quot;There were&quot;, typos, &quot;typos.&quot;)
  
  
  
  
  main()
  </code></pre>
  <p>Thanks for help!</p>