I write mostly music, but I still listen to music while I write. Generally, a song will inspire me to write something, so I'll listen to songs that are similar to what I want to write. They usually don't sound anything alike by the time I'm finished. Sometimes, a song will inspire me for one part (say the verse), but another song will inspire me for another (chorus or bridge or something). So I'll have two or three different types of music going on a playlist so that I can get an overall feel for what I want.
The other day, I wrote a song while listening to The World/Inferno Friendship Society (ska), Otis Taylor (banjo), and Metric. Yesterday I wrote while just listening to a single Coldplay song (I think the only one not sung by Chris Martin).