Added safety to library, added reopen()
Rewrote scanline.py to use reopen()