Refactored File.open code
Code refactor