fixed small error in sofa_writedoc where doc2 object was not found