Updated method to write PiP lines