Fixed file read error

Small issues caused by while loop conditions and use of get instead of
peek for debugging have been fixed

TODO: Determine what's causing the program to crash during rendering