filetools.py: reshuffled a bit