writeIfExists implemented