It links something you observed to what came next, usually with a twist: he gave Je Hoon strawberries, and then; after a few half-hearted reps, nice; she suddenly ripped a page out of her notebook. In the frame 줄 알았더니 it means I thought so, but it turned out otherwise, which two of these lines use. Because it rests on first-hand observation it does not fit your own deliberate actions.