Added some file handling logic, to be tested