Current the function fsi_write_and_advance has two core functionalities from the typical coupling time loop: (1) writing data to preCICE and (2) advancing preCICE.
For clarity it is favourable to separate these two functionalities into separate functions" write_data() and advance().