**I am Proggraming in python however i have come to a slight glich which i cannot solve! The issue is that when it prints out in a text files it only prints one line of the whole ouput! Otherwise it works! Please i need help to make this work!
**
import sys, bz2, string, os
#get filename
filename = raw_input("Enter the path of bz2 document e.g. files/access_log-20130301.bz2: ")
#printfile which is going to be used
print "Using file : " + filename
source_file = bz2.BZ2File(filename, "r")
for line in source_file:
#Extract the date and put into a variable
logdate = string.split(line)[3][1:12]
# Extract movie name and put into variable movie #
movie = string.split(line)[6]
# # extract who read the movie username = # #
usernames = string.split(line)[2]
# #Only process the movie line if we have /media/movie in it. #
if movie.find('media/movies') > 0:
# #Prints all things prosscesed #
print "User:" + usernames + " On:" + logdate + " Was watching:"+ movie
fp=open(filename+"record.txt", "w")
fp.write("User: " + usernames + " On: " + logdate + " Was watching: "+ movie+" File from:"+filename+"\n")
sys.exit()