fixed bug by moving file read section into game loop