Bug fix in write double. Wasn't using the correct variable.