Fixed buggy term.write function