append_query_params() added the parameters after a '#', where the fragment, which is not sent, took them along, and write_request() read a query that came after one. Insert them before the fragment, and leave the fragment out of the query.