Ruby, 3131 25 bytes
$><<p [*DATA][3]?\b;a||=0;a+=1;$><<a/3*2+1;3:1
__END__
This uses Try it online!
Try it online!Try it online!Try it online!
Explanation:
\b__END__
which doesn't work everywhereis not part of the code and everything that follows it is returned by the iterator (tio)DATA
as lines of text, simply count those lines and check if there are enough of them to switch from 1 to 3.