How could i write parent child relation records into flat file


I have a Hierarchical record structure as Record A as parent and It contains 1 or many Record B childs . and Record B contains 1 or many Record C as grant childs . It is just like a tree structure which i want to out put into a file . How can i perform with the File I/O operation templates .

      If i make a configured operation with FixedLength output(hierachical ) then in the integration script how can i assign the tree data to the input of configured operation . 

thanks & regards