File handling logic