avoided a seg fault by moving binmode, and optimized mem usage with a string reference to the file content