save file on BufLeave (could be buggy)