Added dumping of PID to file, if file specified.