Fix file reading and syntax errors