f.write(",".join([str(a) for a in x]) + "\n")

each = x.strip().split(",")


このあたりがわかりません。