Fixed reading response by putting reader and writer in same try-with-resources block