minor improvement in Writing files
no need to load the full file and also in addition into a data frame to get the length of the array in the file
no need to load the full file and also in addition into a data frame to get the length of the array in the file