savetofile: better error handling, more info