Refactoring file.py