Move duplicate code into inline function
Fix some small issues in parse_file function...

* Explicitly multiply length by sizeof(char) when allocating buffer
* Add "b" (binary) to fopen mode flags, to appease Windows