basically you need to add a condition (if statement) in your code that tells the robot to go straight if it does not detect a line otherwise (else) follow the line using PID or any other algorithm. Im not sure how you have your sensors wired to the robot but the theory is, if none of the sensors detect a line assume there is no line and drive straight until it appears again.
Make an attempt to figure out how to implement this "condition" into the code, if you are struggling with this post back with specific questions about what part you are having trouble with. If you plan to use this copied code you will really need to read through it and understand how it works so you can add these modifications.
BTW it looks like the code you are using is actually a PD control loop.