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


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: ???: ??,}

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

val kafkaConf = kafka

// Kafka topic name
// Kafka producer configs
ProducerConfig.ACKS_CONFIG → “1”,
// list of Kafka broker hostname and port pairs
ProducerConfig.BOOTSTRAP_SERVERS_CONFIG → “localhost:9092”,
// Required since Apache Kafka

val scn = scenario(“Kafka Test”)
// 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

scn.inject(constantUsersPerSec(10) during (1 seconds)))


Many thanks