added try-catch for when file/directory creation fails, not when it already exists.