in reply to Error : Segmentation fault

Since Segmentation fault is a runtime exception thrown by Unix OS. You can put the scipt in debug mode or you can use print statements like "I am here" after every line of code to detect which line is spoiling the show. Then you can start debuging once you get the said line.