It definitely feels slightly gross.  How would it look if implemented in the RPython layer?  Kinda like...
````` python
while True:
    w_line = space.send(space.w_kernel, space.newsymbol("gets"), [])
    if w_line is space.w_nil:
        break
    space.globals.set(space, "$_", w_line)
    space.execute(source, filepath=path)
`````