code: def splitFile(inputFileName, linePerFile, outPrefix):
      
      nbTmpFile = 1
      nbLine = 0
      tmpFile = None
      try:
          with open(inputFileName, "r") as inputFile:
              for line in inputFile:
                  row = line.rstrip("\r\n").split(" ")
                  nbLine += 1
  
                  if tmpFile is None:
                      try:
                          tmpFile = open(
                              outPrefix + "_tmp.list%d" % nbTmpFile,
                              "w",
                          )
                      except IOError:
                          msg = "tmp.list%d: can't write file" % nbTmpFile
                          raise ProgramError(msg)
  
                  print >>tmpFile, " ".join(row[:2])
  
                  if nbLine == linePerFile:
                      nbLine = 0
                      nbTmpFile += 1
                      tmpFile.close()
                      try:
                          tmpFile = open(
                              outPrefix + "_tmp.list%d" % nbTmpFile,
                              "w",
                          )
                      except IOError:
                          msg = "tmp.list%d: can't write file" % nbTmpFile
                          raise ProgramError(msg)
          tmpFile.close()
  
          # Check if the number of line is zero (hence the last file is empty)
          if nbLine == 0:
              # We delete the last file
              file_name = outPrefix + "_tmp.list{}".format(nbTmpFile)
              if os.path.isfile(file_name):
                  os.remove(file_name)
              nbTmpFile -= 1
  
      except IOError:
          msg = "%s: no such file" % inputFileName
          raise ProgramError(msg)
  
      return nbTmpFile
docs: Split a file.
  
      :param inputFileName: the name of the input file.
      :param linePerFile: the number of line per file (after splitting).
      :param outPrefix: the prefix of the output files.
  
      :type inputFileName: str
      :type linePerFile: int
      :type outPrefix: str
  
      :returns: the number of created temporary files.
  
      Splits a file (``inputFileName`` into multiple files containing at most
      ``linePerFile`` lines.