Random sample n lines or all lines with probability p