s/writing to code/writing code/

Though I think you could just as well leave out the entire phrase "when writing [to] code" and you wouldn't lose anything.