title: How can I read the API authentication data from a file using Python?
body: <p>I am having trouble with a "Bad Authentication" error when reading my API keys from a file as such:</p>
  
  <pre><code>#!/usr/local/bin/python
  import tweepy
  
  #open a file called "keys" with keys and tokens for Twitter separated by newlines
  keyFile = open('keys', 'r')
  consumer_key = keyFile.readline()
  consumer_secret = keyFile.readline()
  access_token = keyFile.readline()
  access_token_secret = keyFile.readline()
  keyFile.close()
  print "consumer key: " + consumer_key
  print "consumer secret: " + consumer_secret
  print "access token: " + access_token
  print "access token secret: " + access_token_secret
  
  auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  auth.set_access_token(access_token, access_token_secret)
  </code></pre>
  
  <p>If I manually set my keys, like with <code>consumer_key = "xxx"</code>, it works fine. Any tips on why is doesn't work when reading from file? Thanks.</p>