Working version - some refactoring connected with creating FileOutputStream