I have 2 files: "a.txt" and "b.txt" where I want to match lines between them. The files contain the following:
1
2
3
4
5
6
7
8
9
10
To match the lines, I'm doing the following
    a = open("a.txt","r") 
    b = open("b.txt","r")
    for al in a:
        al = al.split()
        val_a = al[0]
        for bl in b:
            bl = bl.split()
            val_b = bl[0]
            print val_a, val_b
Surprisingly, the print statement ONLY prints the following:
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
Which appears to be that the loop on a is only accessed once. What I tried for debugging is the following:
for al in a:
    al = al.split()
    val_a = al[0]
    print val_a
    for bl in b:
        bl = bl.split()
        val_b = bl[0]
The print statement here prints all the values within a
Can someone help me with a possible explanation?
 
     
     
     
     
    