Fix bug in register write

It was sending a read query!