Unless you have an external pullup resistor connected, you need to change pinMode(button, INPUT) to pinMode(button, INPUT_PULLUP).
Is the switch closed at the "home" position, or open?
After you start the motor, you will need to wait for the motor to move away from the home position before you start looking to see whether the switch indicates that the home position has been reached again.
to start the motor, you need to keep the motor on until the switch closes, before you proceed to wait for the switch to open again. Try inserting this after that line:
while (digitalRead(sw) == HIGH) { }
delay(10);
The first line waits for the switch to close and the second one allows for contact bounce. Alternatively, just use delay(1000) so that the motor runs for at least one second, which is hopefully long enough for the switch to close.