fix query file and accept q to quit