two tiny python questions : <pre><code>fn = raw_input("Enter file to open: ")
fileObject = open(fn,'r+')
dictionary = {}
for line in fileObject:
    x = line.split(":")
    a = x[0]
    b = x[1]
    c = len(b)-1
    b = b[0:c]
dictionary[a] = b
print dictionary
</code></pre>

<p>After I tested my program, I found out everything were perfect except for 2 tiny issues. Can you please tell me what is wrong?</p>

<p>My text file has the following in it:</p>

<p>username1:password1</p>

<p>username2:password2                                              </p>

<p>username3:password3</p>

<p>username4:password4</p>

<p>username5:password5</p>

<p>(This is an empty line in the actual text file)</p>

<p>First problem:
       My program reads the file into a dictionary perfectly but it is reading <strong>out of order</strong>, i tried to print the dictionary after the reading into the dictionary part and below is what I got.</p>

<pre><code>   {'username1': 'password1', 'username3': 'password3', 'username2': 'password2', 'username5': 'password5', 'username4': 'password4'}
</code></pre>

<p>Second problem:</p>

<p>for the text file, after password5, I have to hit enter and save the text file to get this:</p>

<pre><code>   {'username1': 'password1', 'username3': 'password3', 'username2': 'password2', 'username5': 'passwor**d5'**, 'username4': 'password4'}
</code></pre>

<p>if I don't hit enter at the end of the text file, then it will become this:</p>

<pre><code>    {'username1': 'password1', 'username3': 'password3', 'username2': 'password2', 'username5': 'passwo**rd'**, 'username4': 'password4'}
</code></pre>
