Made changes according to review comments. Added a check if the FILE* is valid to prevent errors (there was a failing unit test).