Let $M,N$ be $R$-modules with $M$ finitely generated and let $S\subseteq R$ be multiplicatively closed. Then there exists a module isomorphism $$S^{-1}\text{Hom}_R(M,N) \xrightarrow{\sim} \text{Hom}_{S^{-1}R}(S^{-1}M,S^{-1}N).$$
As homework, I found a 'proof' of this statement. However, Does localisation commute with Hom for finitely-generated modules? claims to prove me wrong. I am having trouble in finding the error in my proof. Could someone help me out?
I did prove there exists a map $\phi:S^{-1}\text{Hom}_R(M,N) \to\text{Hom}_{S^{-1}R}(S^{-1}M,S^{-1}N)$ defined by $f/s\mapsto(m/t\mapsto f(m)/st)$, and I am fairly confident that it contains no mistake.
Proof: Let $m_1,\dotsc,m_n$ be the generators for M. Let $f\in \text{Hom}_{S^{-1}R}(S^{-1}M,S^{-1}N)$ be given. Choose $n_i\in N$ and $s_i\in S$ such that $f(m_i/1)=n_i/s_i$. Define $\pi_f = s_1\dotsm s_n$. Then $$\pi f(m/1) = \pi f\left( \sum_{i=1}^n r_i m_i \right) = \pi \sum_{i=1}^n r_i f(m_i) = \pi \sum_{i=1}^n r_i n_i/s_i = \left(\sum_{i=1}\left(\prod_{j=1, j\neq i}^n s_i\right)r_in_i\right)/1,$$ so $\pi f(m/1) \in N$ using the canonical embedding in $S^{-1}N$, so $m\mapsto \pi f(m/1)$ is a map $M\to N$ and is clearly an homomorphism.
If we define the map $\psi:\text{Hom}_{S^{-1}R}(S^{-1}M,S^{-1}N)\to S^{-1}\text{Hom}_{R}(M,N)$ as $$ f \mapsto (m\mapsto \pi_f f(m)) / \pi_f,$$ then we clearly have a homomorphism if it is well-defined.
Proof: It remains to check that the element we map to does not depend on choice of $\pi_f$. But if we have both $\pi_f$ and $\pi_f'$ for which $\pi_f f$ and $\pi_f' f$ are homomorphisms to $N$, then $$(\pi_f f(m))/\pi_f = (\pi_f\pi_f' f(m))/(\pi_f\pi_f') = (\pi_f' f(m))/(\pi_f')$$ for all $m\in M$, so $\psi$ is in fact well defined.
It is now easy to check that $\psi$ and $\phi$ are inverses, which makes them homomorphisms.