Adding an exception handling during write.