I don’t know about you, but I’ve heard this saying more times than once. And I have to say I agree. It is easier to write things you know about. However I don’t think that we should stick in our comfort zone. Writing can be a good way to learn new things and explore topics you haven’t gotten the chance to. This is especially true when you are writing fantasy, science fiction or even crime fiction. These genres often have elements that you have to make up, and as much as you can try to make them realistic at some point you are going to have to go with your gut and just write it.
The truth to the write what you know ‘rule’ is that you need to use elements of what you know to make your writing more realistic. Have you recently been on holiday to a place similar to the one you are writing about? Use the picture in your head to improve your descriptions. Do you have a relationship similar to one of the ones in your writing? Use those emotions to make the interactions between the characters seem more real. Have you ever been in a situation where you feel similar to what your character is feeling? Use that experience to convey what it is like to your readers.
There are so many ways that you can use your experiences to enhance your writing even if the situation doesn’t completely line up. Having never cast a spell, or been another gender, or another race (etc.) should never stop you from writing a character who is. A writer is someone who looks at their experiences and adds embellishment to make them into engaging stories. A good writer is someone who can pull apart their experiences and weave them into something completely different.
That is why when I go to write a scene with a particular emotion I think of an occasion when I was feeling that. When I go to describe a setting I think of my experiences in a similar setting, and it makes the writing better. When I have a picture in my head, feelings to describe, imagery to use, the writing becomes a lot easier and a lot better.