def serialize_array checking if folder where data is supposed to be written does exist