Slightly lower level file scanner written in Python