put freeSpace in write function while no space