better query-sparql script (regarding file handling)