use advice instead of hook for writing the file

on 24.4 it appears that the window configuration change hook is run and
clears all windows just before the call to writing the file.

fixes #7.