moved the responsibility of file opening to the resource class