Error corrections + debugging
Changed fprintf to err
Forgot one parameter