fix writepgm