Starting and ending regular expression

I want to issue an alert when only a dot in a line.
It needs check for starting and ending regular expression.

Is it a character string starting with 〇〇?

preg_match("/^xx/", $char);

Is it a character string ending with 〇〇?

preg_match("/xx$/", $char);

Here is the main theme. When judging whether it is a character string of only dots, combine the above.

$char = '.';

if(preg_match('/^.$/', $char)){
	echo "please write again.";
} else {
	echo "OK";
}

-> please write again.

Yes, it is as expected.
I would like to apply next. Read the file and if there is a line with only dots, it will issue an error.

this is a popular Hamlet.
test.txt

To be, or not to be: that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them? To die: to sleep;
No more; and by a sleep to say we end
The heart-ache and the thousand natural shocks
That flesh is heir to, 'tis a consummation
Devoutly to be wish'd. To die, to sleep;

app.php

$file = fopen("text.txt", "r");

if($file){
	while($line = fgets($file)){

		if(preg_match('/^.$/', $char)){
			echo "please write again.<br>";
		} else {
			echo "OK<br>";
		}

	}
}


It is looks like it is going well😂