The writhe of knots in the cubic lattice