親フォルダ タブ
<?php
session_cache_limiter('nocache');
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" name="viewport">
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css">
</head>
<body>

<form>
学籍番号 <input type="text" name="r101">
<input type="submit" name="send" value="送信">
</form>

<pre>
<?php

$target = "log/data_" . session_id() . ".txt";

if ( file_exists( $target ) ) {
	$text = @file_get_contents( $target );
}
else {
	$text = "";
}

// 現在の内容を一番前に置いたテキストを作成する
$text = $_GET["r101"] . "\r\n" . $text;

// テキストをそのまま書き込む
file_put_contents( $target, $text );

// 全てを表示
print file_get_contents( $target );

?>
</pre>

</body>
</html>
ファイルの読込みと書き込み部分の行数が多くなって来たので、関数として別の場所で記述したほうが可読性が良くなります