extracting file-related logic into file class