I'm currently trying to make an address book that can store data in a .txt file.

print "Virtual Address Book"
print "Austin Jackson; Project 4 : Jun 14, 2008"
print " "
print "1. Add New Contact Information"
print "2. View Adress Book"
choice = input(">")

if choice == 1:
    name = raw_input("Contacts Name:")
    address = raw_input("Contacts Address:")
    number = raw_input("Contacts Number:")
    email = raw_input("Contacts Email:")

    out_file = open("address.txt", "w")
    out_file.write("Contacts Name: ")
    out_file.write(name + "\n")
    out_file.write("Contacts Address: ")
    out_file.write(address + "\n")
    out_file.write("Contacts Number: ")
    out_file.write(number + "\n")
    out_file.write("Contacts Email: ")
    out_file.write(email + "\n")

if choice == 2:
    in_file = open("address.txt", "r")
    text = in_file.read()

That is what I have so far. I have two problems:
1. Every time I enter a new contact the previous contact gets over written.
2. I cannot display my address (choice 2)... Though I think my code is correct...

Help would be appreciated,

out_file = open("address.txt", "w")

Change this to
out_file = open("address.txt", "a")
You want to "a"=append to, not "w"=write over. And to start you out

if choice == 2:
    in_file = open("address.txt", "r")
    text = in_file.readlines()
    print text
This question has already been answered. Start a new discussion instead.