<div class="gmail_quote">
<div>hi everyone, I&#39;m a bit new here but i was wondering if someone could check some of my code, it&#39;s not doing quite what it&#39;s meant to. the problem is when you start the application again and enter the databox.txt to load from</div>


<div>thanks</div>
<div> </div>
<div>Databox_2_0.py:</div>
<div> </div>
<div>import sys, os<br>pygame.init()</div>
<div>def load(filename):<br>    if filename != &#39;&#39;:<br>        e = 1<br>        dec = &quot;placeholder&quot;<br>        fic = open(filename, &quot;r&quot;)<br>        while dec != &#39;&#39;:<br>            num = str(e)<br>

            print &quot;found &quot; + num + &quot; enteries&quot;<br>            dec = fic.readline(e)<br>            databox[e] = dec<br>            dec = fic.readline((e+1))<br>            databox2[e] = dec<br>            e = e+1<br>

        fic.close()<br>    else:<br>        return 0</div>
<div>def search():<br>    print &quot;\n&quot;<br>    x = 1<br>    items = len(databox)<br>    ins = items+1<br>    while ins &gt; x :<br>        dac = databox[x]<br>        dac2 = databox2[x]<br>        x = x + 1<br>        print dac + &quot; &quot; + dac2<br>

    print &quot;\n\n&quot;<br>        </div>
<div>def add():<br>    dat = raw_input(&quot;First name.\n&quot;)<br>    dat2 = raw_input(&quot;\nSecond name.\n&quot;)<br>    items = len(databox)<br>    ins = items+1<br>    databox[ins] = dat<br>    databox2[ins] = dat2<br>

    print &quot;Done.\n\n&quot;</div>
<div>def exitprog():<br>    fic = open(&#39;databox.txt&#39;,&#39;w&#39;)<br>    print &quot;saveing\n&quot;<br>    x = 1<br>    items = len(databox)<br>    ins = items+1<br>    while ins &gt; x :<br>        dac = databox[x]<br>

        dac2 = databox2[x]<br>        x = x + 1<br>        fic.write(dac)<br>        fic.write(dac2)<br>    fic.close()<br>    print &quot;goodbye&quot;<br>    pygame.time.delay(900)<br>    exit()</div>
<div>databox = dict()<br>databox2 = dict()<br>go = raw_input(&quot;filename, blank for none.\n&quot;)<br>load(go)<br>while True:<br>    print &quot;Welcome to databox V2.0.&quot;<br>    print &quot;     1. Searth the database.&quot;<br>

    print &quot;     2. Add a record.&quot;<br>    print &quot;     3. Exit.&quot;<br>    inme = raw_input(&quot;Please make a selection.\n&quot;)<br>    if inme == &quot;1&quot;:<br>        search()<br>    elif inme == &quot;2&quot;:<br>

        add()<br>    elif inme == &quot;3&quot;:<br>        exitprog()<br>    else:<br>        print &quot;input not recignised.&quot;<br></div></div><br>