writing everything to files almost complete