list-holidays opens a new buffer called
*Holidays* and makes it visible, but leaves the current buffer unchanged. Meanwhile
write-file writes the contents of the current buffer to a file. Thus your code writes the wrong thing to the file. You can call
switch-to-buffer to change which buffer is current, but you probably also want to restore the window configuration afterwards.
You probably want to do something like this:
(list-holidays 2020 2021)
save-window-excursion saves the current window configuration, runs the code you give it just like progn would, then restores the window configuration. It also saves the state of the buffer you are in as well (point and mark and suchlike).
The code inside opens the holidays window, switches to it, and then writes it to a file.
Edit: Incidentally, I took a peek at the
list-holidays function before writing my answer, because as lawlist says there could be a better function to use. Ideally there would be one that returns a string, or just puts the text in the current buffer. Sadly no such function exists, though it wouldn’t be terribly hard to split the current
list-holidays in half if you wanted.