I've been trying to prove the following result:
Let $X$ be an affine variety over an algebraically closed field $k$, $A=\Gamma(X,\mathcal{O}_X)$, $M$ an $A$-module of finite type, $\mathcal{F}=\widetilde{M}$ the associated sheaf on $X$, and $x\in X$.
Let $\mathfrak{m}_x=\{f\in A\mid f(x)=0\}$, and $k(x)=A/\mathfrak{m}_x\cong k$. We define $\mathcal{F}(x)=M\otimes_Ak(x)$.
Then $\mathcal{F}(x)$ is a finite dimensional $k$-vector space, and $$U_n=\{x\in X\mid\text{rank}_k(\mathcal{F}(x))\leq n\}$$ is an open subset of $X$ for any $n\geq1$.
I think I have a proof, but am unsure about a few steps and would appreciate some verification.
For the first claim, since $M$ is of finite type we have $M=Am_1+\cdots+Am_s$ for some $s\geq1$ and $m_j\in M$. Then for any $x\in X$, we have that $m_1\otimes_A1,\ldots,m_s\otimes_A1$ generate $\mathcal{F}(x)$ over $k(x)\cong k$, so $\text{rank}_k(\mathcal{F}(x))\leq s$ and $\mathcal{F}(x)$ is a finite dimensional $k$-vector space.
For the second claim, choose an arbitrary $n\geq 1$. My aim is to prove that for each $x\in U_n$ we can find some $f_x\in A$ such that $x\in D(f_x)\subseteq U_n$. Then we would have that $U_n=\cup_{x\in U_n}D(f_x)$ is open and the claim would follow.
Take any $x\in U_n$. We have $$\mathcal{F}(x)=M\otimes_AA/\mathfrak{m}_x=M/\mathfrak{m}_xM$$ and we know that $\mathcal{F}(x)$ is generated by some $\overline{x_1},\ldots,\overline{x_n}$ over $A/\mathfrak{m}_x$. Then by Nakayama's Lemma we have that $x_1,\ldots,x_n$ generate $M_f$ as an $A_f$-module for some $f\in A\setminus\mathfrak{m}_x$, where $x_j+\mathfrak{m}_x=\overline{x_j}$.
We know $x\in D(f)$ since $f\notin\mathfrak{m}_x$, now take any $y\in D(f)$. The aim is to show that $y\in U_n$ to conclude that $D(f)\subseteq U_n$. We have that $\mathcal{F}(y)$ is generated by some $\overline{y_1},\ldots,\overline{y_t}$ over $A/\mathfrak{m}_y$ since we proved any fibre was finite dimensional over $k\cong k(x)$, and we can find $y_i\in M$ with $y_i+\mathfrak{m}_y=\overline{y_i}$. Then for each $i$ we have $$y_i=\frac{a_1x_1+\cdots+a_nx_n}{f^m}$$ for some $a_j\in A$, $m\geq0$, since the $x_j$ generate $M_f$ as an $A_f$ module (we can assume a common denominator by adding more $f$s into the $a_j$ if necessary).
Then $$f^l(f^my_i-(a_1x_1+\cdots+a_nx_n))=0$$ for some $l\geq0$ from the definition of equality in the localisation. Since $A/\mathfrak{m}_y$ is a field, there exists some $g\in A$ such that $(gf^{l+m}-1)\in\mathfrak{m}_y$. Then setting $b_j=gf^l$ we get $$y_i-(b_1x_1+\cdots+b_nx_n)\in\mathfrak{m}_y\tag{*}$$ by multiplying through by $g$, so $$y_i+\mathfrak{m}_y=b_1x_1+\cdots+b_nx_n+\mathfrak{m}_y$$ Then the $(x_j+\mathfrak{m}_y)$ generate $\mathcal{F}(y)$ as an $A/\mathfrak{m}_y$-module, so $\text{rank}_k(\mathcal{F}(y))\leq n$ and we are done.
It's the step $\text{(*)}$ that I'm unsure about, are the $A_f$ and $A/\mathfrak{m}_y$ actions compatible in the way I've used them? I think since they're both ultimately derived from the action of $A$ on $M$ it should be alright, but I just wanted to make sure.
If I've made any other mistakes I'd also appreciate having them pointed out, this seems an important exercise and so I want to make sure my proof is correct! Many thanks in advance.
Note: I've updated the first step of my proof to try to clarify some issues raised in the comments, and have also made a few steps more explicit.