Fixed exception thrown when setting writing