firstly you shall not assign the readed line to $line variable, you shall use $line[], so you can have a array variable with incremented number order as keys, and some more addons...
function getmyfile()
{
$file_handle = fopen("/home/powerabc/public_html/demo/demo.txt", "r");
while (!feof($file_handle))
{
$userfile = fgets($file_handle);
$line[] = explode(".",$userfile); // $line must be array
}
fclose($file_handle); // no need to be opened that much time
echo $line[0];
$rand=rand(1, count($line)); // so you will have a random number between start and end of your array
$valu = ''; // actually if you initialize your variables, you get more error free code
for ( $countr=0; $countr < $rand; $countr+=1){
$valu = $valu . $line[$countr]; // this makes more sense to me, cause you can get same lines
echo $valu;
}
return $valu;
}