If you were trying to develop a skill, and you took that advice, what would happen? If I’m trying to learn to draw human faces, and someone said, “only draw what you know”, I’d spend the rest of my life drawing smiley faces and stick figures a seven year old would be ashamed of.
It’s only by writing what you don’t know, by attempting to draw what you find difficult, by trying to do what you haven’t quite got the hang of that you progress. To do otherwise is to stay comfortable, to remain within your boundaries. Have you ever heard of anyone getting better by playing it safe? Imagine a child learning to ride a bike. At some point, the stabilisers have to come off. Yes, they might fall a few times. It might terrify them and their parents to see them careening down the road, wobbling all over the place. But it’s a necessary part of the learning process.
You can stick to writing what you know. But understand that, by doing so, you’re ensuring that all you’ve ever know in the future is what you know in the present. And I bet that, right now, you don’t know it all.