Here is a small solution in python using groupby and str.rpartition:
from itertools import groupby
with open("in_file.txt") as f_in:
for name,lines in groupby(f_in.readlines(),key=lambda x:x.rpartition(" ")[2].strip()):
with open(f"out_{name}.txt","w") as f_out:
f_out.writelines(lines)