septillion:
OP made me look like a fool by adding code and deleting posts... No clue there was a switch before.
I missed that OP edited the original post. My apologies for thinking that you missed the fact that the write happened only when the switch was pressed.