Need Help with gatling on looping over line by line within Scenario

Hi,

I have file that contains text something like this

{“content_type”:“Twitter”,“id”:“77f985b0-a30a-11e5-8791-80000bc51f65”,“source_id”:“676656486307639298”,“date”:“2015-12-15T06:54:12.000Z”,“text”:"RT @kokodeikku_bot: ???: ??,}
{“content_type”:“Twitter”,“id”:“7837a020-a30a-11e5-8791-80000bc51f65”,“source_id”:“676656494700568576”,}
{“content_type”:“Twitter”,“id”:“7838d8a0-a30a-11e5-8791-80000bc51f65”,“source_id”:“676656507266703360”,}

I’m unable to post one line at a time as String to a kafka topic within scenario since i cant iterate over a scenario in gatling, Please suggest how to iterate over a file and read line by line in scenario:

Here is my code

class KafkaSimulation extends Simulation {

val line = Source.fromFile()(“UTF-8”).getLines.mkString("\n") // one way by reading source from file

val br = new BufferedReader(new FileReader(""))
var line:String = “”

while ({ line = br.readLine() ; line != null } ) {
//In this while loop i can print line by line but i cant use while loop within scenario below
println(listOfLines.mkString("\n"))
}

val kafkaConf = kafka

// Kafka topic name
.topic(“test”)
// Kafka producer configs
.properties(
Map(
ProducerConfig.ACKS_CONFIG → “1”,
// list of Kafka broker hostname and port pairs
ProducerConfig.BOOTSTRAP_SERVERS_CONFIG → “localhost:9092”,
// Required since Apache Kafka 0.8.2.0
ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG →
“org.apache.kafka.common.serialization.ByteArraySerializer”,
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG →
“org.apache.kafka.common.serialization.ByteArraySerializer”))

val scn = scenario(“Kafka Test”)
.exec(kafka(“request”)
// message to send
.send(line.toString())) //Here if i put line.toString(), it doesnt read line by line instead it will post entire 3 lines as one message

setUp(
scn.inject(constantUsersPerSec(10) during (1 seconds)))
.protocols(kafkaConf)

}

Many thanks
mpha