start refactoring: read source file by char instead of line-by-line reading