Localization commutes with Hom for finitely-generated modules 
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.
 A: The problem with your argument is quite subtle: you can't say $\pi f(m/1)\in N$, because the canonical homomorphism $i:N\to S^{-1}N$ may not be injective (because elements of $S$ might annihilate elements of $N$).  That is, there is always some element $n\in N$ such that $i(n)=\pi f(m/1)$, but that $n$ might not be unique, and it is not clear that you can choose such an $n$ for each $m$ such that the map $M\to N$ you obtain is a homomorphism.  This problem does not occur if $S$ acts on $N$ by non-zero divisors (i.e., $sn=0$ implies $n=0$ for $s\in S$, $n\in N$), because then $i$ is injective.
In general, in fact, there might not be any way to choose an $n$ for every $m$ such that you get a homomorphism.  For instance, let $R=k[x,y_1,y_2,y_3,\dots]$ be a polynomial ring in infinitely many variables, let $M=R/(y_1,y_2,y_3,\dots)$, let $N=R/(xy_1,x^2y_2,x^3y_3,\dots)$, and let $S=\{1,x,x^2,\dots\}$.  Then it is not too hard to see that there are no nonzero homomorphisms $M\to N$ (for an element of $N$ to be annihilated by every $y_n$, it would need to be infinitely divisible by $x$).  But $S^{-1}M$ and $S^{-1}N$ are actually canonically isomorphic: both can be identified with $k[x,x^{-1}]$ with every $y_n$ acting trivially.  In particular, this means $\operatorname{Hom}_{S^{-1}R}(S^{-1}M,S^{-1}N)$ is nonzero (it contains an isomorphism), whereas $S^{-1}\operatorname{Hom}_R(M,N)=S^{-1}0=0$.  It is a good exercise to run through your proof with this example and see exactly how it breaks down.
To make the proof work in general, you need $M$ to be finitely presented, not just finitely generated.  The idea behind the proof is then to choose an $n_i\in N$ lifting $\pi f(m_i/1)$ for each generator $m_i$ of $M$, where you choose $\pi\in S$ not just such that such a lift exists but also such that these $n_i$ will satisfy all of the finitely many relations between the $m_i$.  This implies that the map $m_i\mapsto n_i$ extends to a well-defined homomorphism $M\to N$.
A: The mistake is in the sentence: 'and is clearly a homomorphism' (there is a choice of the $r_i$, they are not unique).
