Q:

Appending a new line to file

I am wondering how to append a newline every time the list reaches the size of the checker board (8). Heres my code so far. It works but I want to put a newline every 8 characters.
 saveFile=input("Please enter the name of the file you want to save in: ")
  outputFile=open(saveFile,"w")
  pieceList=[]
  for row_index in range (self.SIZE):
     for column_index in range(self.SIZE):
        pieceRow=[]
        char=" "
        if self.grid[row_index][column_index]==Piece(Piece.WHITE):
           char="w"
        elif self.grid[row_index][column_index]==Piece(Piece.RED):
           char="r"
        pieceRow.append(char)
     pieceList.append(pieceRow)
     for item in pieceList:
        for char in item:
           outputFile.write("%s" %char)

A:

saveFile=input("Please enter the name of the file you want to save in: ")
  outputFile=open(saveFile,"w")
  pieceList=[]
  characterCounter =0
  for row_index in range (self.SIZE):
     for column_index in range(self.SIZE):
        pieceRow=[]
        char=" "
        if self.grid[row_index][column_index]==Piece(Piece.WHITE):
           char="w"
        elif self.grid[row_index][column_index]==Piece(Piece.RED):
           char="r"
        pieceRow.append(char)
        characterCounter++
        if characterCounter==8:
           pieceRow.append("\n")
           characterCounter=0
     pieceList.append(pieceRow)
     for item in pieceList:
        for char in item:
           outputFile.write("%s" %char)

