Updated File handling procedure