stepper control

hi guys.
im new but learning quickly, i did this code to control a stepper with optic sensor, pulling a label roll reading the label till space on roll in between labels, all works fine, but i need a eye to see when label is gone to continue again. i thought about using a LDR any other suggestions pls.
can someone direct me to a place on teaching me how to use these brackets properly { } ?

[/code]

//*
//  Control of a 4 wire stepper motor with optical-sensor (TCST2103) high and low
//  readings with led confirming sensor status, reading 28mm x 32mm label on a roll
//  sensor reading 28mm edge of label.
//  optical - Sensor controlled with LM393N on seperate pc board 5vDC 
//*
 #include <Stepper.h>
 //#include <AccelStepper.h>
 //#include <MultiStepper.h>
  const int led = 13;        // led indicator on pin 4
  const int sensor = 2;      // sensor on pin 19
  const int stepsPerRevolution = 200;     // 1.8 degree step motor
  int state = LOW;     // default, no motion detected
  int val = 0;       // variable to store the sensor status (value)
              // initialize the stepper library on pins 9 through 12:
  Stepper myStepper(stepsPerRevolution, 9, 10, 11, 12);
  int stepCount = 0;        // number of steps the motor has taken

void setup() {  
  pinMode(led, OUTPUT);     // initialize LED as an output
  pinMode(sensor, INPUT);   // initialize sensor as an input
}

void loop() {
    val = digitalRead(sensor); // read sensor value
    if (val == LOW)  {        // check if the sensor is LOW
    digitalWrite(led, LOW);   // turn led off
 } else {
    digitalWrite(led, HIGH);    // turn led on
    int sensorReading = analogRead(A0);   // pot to adjust motor speed.
                      // map it to a range from 10 to 255:
    int motorSpeed = map(sensorReading, 0, 1023, 10, 255);
                     // set the motor speed:
    if (motorSpeed > 0)
      myStepper.setSpeed(motorSpeed);
                     // step 1/200 of a revolution:
    myStepper.step(stepsPerRevolution / 200);
    //val = digitalRead(sensor); // read sensor value
   //if (val == HIGH)
    // myStepper.step(40);
  }
}

Use a photo-transistor - LDRs are very slow to respond.

'{' and '}' group statements whereever they are used inside a function definition, if, for, while, switch -
these require only a single statement inside them, but a {} group counts as a single statement syntactically.

{} also allows local variables to be declared that shadow those further out, and {} are used for array
initialisers. Think that's all.