I am very new to Teensy-Audio so please be patient with me

I want extend the Audio-Example: "Part_2_03_Samples" so the sample-playing is beeing recorded.. a simple looper.

1) when no RECORD.RAW is beeing found, that means a new loop has been startet.. so record LineOut to RECORD.RAW and play it immediately after ending in a loop.
2) when RECORD.RAW has been found, that means overdub, record LineOut to OVERDUB.RAW, .. here I would need to delete RECORD.RAW, rename OVERDUB.RAW to RECORD.RAW and play this file in a loop now.

I thought about wiring the LineOut directly to LineIn, so it can be recorded from here.. and the output would be the headphone-jack.
But I think there is a better way, which I don't know. Maybe in the Audio-Tool somehow route somewhat to something(?).

I am sitting on this for a week now (since I unfortunately have not much time, beside wife, kids and job, which I can spend on this) .. reading all I find and trying out, but I can't figure out, how that would work..

is there maybe a example how live-recording/looping would work? What is the best way to route the played samples to somehow be recorded?