Fixing error using empty on write context