Added logging, input target file and detection of scan stopping.