title: Read a text file line-by-line into a string with python
body: <p>I have made a keylogger with python that encrypts and saves keylogs as numbers to a textfile (data.txt). I also wanted it to send the encrypted keylogs (numbers) to my gmail account using smtplib. <strong>the problem is that i get this output:</strong></p>
  
  <pre><code>5
  5
  6
  5
  6
  2
  1
  0
  4
  4
  4
  7
  5
  9
  5
  \
  ,
  4
  2
  3
  8
  6
  9
  1
  0
  1
  5
  3
  7
  2
  5
  6
  \
  </code></pre>
  
  <p>Instead of this:</p>
  
  <pre><code>123456789108765
  682371638321237
  </code></pre>
  
  <p><strong>I have been using this code to get all text from the textfile as a list:</strong></p>
  
  <pre><code>with open("data.txt") as f:
                  x=(f.readlines())
  </code></pre>
  
  <p><strong>And this code to get all items from that list and print them line by line:</strong></p>
  
  <pre><code>x = '\n'.join(map(str, x))
          print(str(x))
          message = str(x) # this message gets sent to my gmail account
  </code></pre>
  
  <p>If you feel that this question is misssing some information that you may need to answer my question then i would be glad to include that information in my question!</p>
  
  <p>Thanks in Advance :)</p>