I am making a system that reads a file, moves it to a new file, and moves it back with a new variable at the end of each line.
It is saying that linesRead is referenced before assignment
import random
handVar = 0
handList = []
linesRead = 'test'
def dealCards(numPlayers, cardList):
    random.shuffle(cardList)
    for i in range(0, numPlayers):
        poppedCard1=cardList.pop()
        poppedCard2=cardList.pop()
        hand = (poppedCard1 + ', ' + poppedCard2)
        handList.append(hand)
        cardFile = open('players.txt', 'r')
        playerLines= cardFile.readlines()
        cardFile.close()
        for i in playerLines:
            for f in i:
                linesRead = linesRead + f
        print(linesRead)
        tempFile = open('tempFile.txt', 'w')
        tempFile.write(playerLines)
        tempFile.close
        tempFile = open('tempFile.txt', 'r')
        playerFile = open('players.txt', 'a')
         for i in tempFile:
            newLine= (i + ', ' + handList[handVar] + ', ' + handList[handVar+1])
            playerFile.write(newLine)
            handVar = handVar + 2
 
     
    