# Tile lines to CSV
 #
 # n_per_line: number of elements per line
 # in_file: path name of input
 # out_file: path name of output

 def make_line(lst: list) -> str:
     return ",".join([f"\"{i}\"" for i in lst])
 with open(in_file) as f:
     with  open(out_file, "w") as w:
         w.write(make_line([f"{str(i)}" for i in range(n_per_line)]) + "\n")
         lst = []
         for i, smi in enumerate(f.readlines()):
             if i != 0 and i % n_per_line == 0:
                 w.write(make_line(lst) + "\n")
                 lst = []
             smi = smi.strip()
             lst.append(smi)
         while len(lst) < n_per_line:
             lst.append("")
         w.write(make_line(lst) + "\n")