I was asked to prove that if $f\in\mathscr{R}$ on some compact rectangle $Q\subset\mathbf{R}^{n}$ and if the set $D=\lbrace \mathbf{x}:\mathbf{x}\in Q,\,f(\mathbf{x})\neq 0\rbrace$ has measure zero, then $\int_{Q}f = 0$. I came up with a suspiciously "quick" proof for this fact and I'm not confident with it. Could anyone verify it for me?
$\textbf{Proposition. }$ Let $Q$ be a compact rectangle in $\mathbf{R}^{n}$ and let $f:Q\to\mathbf{R}$ be a Riemann-integrable function on $Q$. If the set $D=\lbrace \mathbf{x}:\mathbf{x}\in Q,\,f(\mathbf{x})\neq 0\rbrace$ has measure zero, then $\int_{Q}f = 0$.
$\textit{Proof. }$ Suppose that $\left\vert\int_{Q}f\right\vert>0$. Then, there exists a partition $P\in\mathscr{P}(Q)$ such that for every $P^{*}=\lbrace I_{1},I_{2},\cdots,I_{m}\rbrace$ finer than $P$ and for every choice of $\mathbf{t}_{k}\in I_{k}$ we have $$ \left\vert\sum_{k=1}^{m}f(\mathbf{t}_{k})\mu(I_{k})-\int_{Q}f\right\vert<\left\vert\int_{Q}f\right\vert $$ Since $D$ has measure zero, for each $k$ we can find $\mathbf{t}_{k}\in I_{k}$ such that $\mathbf{t}_{k}\notin D$. Choosing these, we would get $\left\vert\int_{Q} f\right\vert<\left\vert\int_{Q} f\right\vert$. Contradiction.$$\tag*{$\square$}$$