t3701: use test_write_lines and write_script