Why would lines[i] be null when you're printing out the line?

Please use curly braces around every for loop and if statement body, even if you think it's only a single line. It also would help if...