What would the code look like if I was trying to do something like this:

-----
//file1.txt

TITLE1
hello
TITLE2
Goodbye
------

1. IF A = 1 THEN
Read what's under TITLE1 (only) into a STRING
ELSEIF A > 1 THEN
Read what's under TITLE2 (only) into a STRING
END IF

2. Write stored string to File2.txt


Thanks for any help