with open('input') as fin, open('output','w') as fout:
for line in fin:
fout.write(line)
if line == 'xxxxx
':
next_line = next(fin)
if next_line == 'yyyyy
':
fout.write('my_line
')
fout.write(next_line)