Cleaning up problem.Initially I used StringBuffer reader and ran into performance issues. Used Scanner to solve the issue.