changed writelines method ddefinition to write the lhs to a file