rewrite .q and .out file