Why is my Code Printing the same Last Name?
<p>The Code Below I wrote takes input from a sample file which contains First and Last names. Then it converts those names to sample emails. For some reason the Script keeps printing the same Last name over and over.  </p>

<p>namess.txt looks like this:
firstname,lastname</p>

<p>CODE: </p>

<pre><code>import os, re, time, getpass, linecache

Original = os.path.join(os.path.expanduser('~'), 'Desktop','namess.txt')
File = os.path.join(os.path.expanduser('~'), 'Desktop','output.txt')
badNames = []
Names = []

def RemCommas():
    outfile = open(os.path.join('C:\\', 'Users', getpass.getuser(), 'Desktop','output.txt'),'w')
    Filedata = open(Original).read()
    outfile.write(re.sub(',', ' ', Filedata))
    outfile.close()

def ClassNum():
    count = 6
    Year = int(time.strftime('%Y'))
    Class = str((Year - 2013) + 6)
    return Class

def ReadStoreFile():
    i = 0
    OpenFile = open(File) 
    LenFile = len(OpenFile.readlines())
    while i &lt; LenFile:
        i += 1
        badNames.append(linecache.getline(File, i))

def CleanNames():
    i = 0
    while i &lt; len(badNames):
        cleaned = badNames[i].rstrip()
        Names.append(cleaned)
        i += 1

def NamePrint():
    Interns = 'makchessclub.org'
    arrayname = []
    i = 0
    j = 0
    m = 0

    while m &lt; len(Names): 
        Name = Names[m]
        Name = Name.lower()
        InternName = Name[0] + Name[1]
        #------------Checking for space and first name--
        while i &lt; len(Name):
            if Name[i] == ' ':
                i = Name.index(' ')
                break;   
            i += 1
        #---------------adding last name in an array----
        Namelen = len(Name) - (i+1)
        while j &lt; Namelen:
            arrayname.append(Name[i+1])
            j += 1
            i += 1
        #---------------Final Name Print----------------
        Lastname = ''.join(arrayname)
        #print arrayname
        #Lastname = Lastname.strip(' ')
        #print InternName + Lastname + ClassNum() + Interns
        file = open('C:\\Users\\username\\Desktop\\emails.txt', 'a')
        file.write(InternName + Lastname + ClassNum() + Interns + '\n')
        file.close()
        m += 1

RemCommas()
ReadStoreFile()
CleanNames()
NamePrint()

print ''
os.system('pause')    
</code></pre>
