I would pass the file object instead of the lines.