from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener


con_key=""
con_sec=""
acc_token=""
acc_sec=""

oauth=OAuthHandler(con_key,con_sec)
oauth.set_access_token(acc_token,acc_sec)

class listener(StreamListener):
    def on_data(self,data):
        file=open("tweetdata.txt",'a')
        file.write(data)
        file.close()
        return(True)
    def on_error(self,status):
        print (status)
       
twit_stream=Stream(oauth,listener())
twit_stream.filter(track=[""])