書式
io.input(ファイル名)
while true do
 変数名 = io.read()
 if 変数名 == nil then break end
end
				
			
				
説明
					Luaでテキストファイルの全ての内容を読み込むにはio.input()でファイル名を指定します。次にwhileを使って読み込んだデータがnilの場合、ループから抜けます。これで、ファイルの末尾まで読み込むことができます。なお、以下のサンプルはMacOS Xの場合、ホームフォルダ内にあるsample.txtファイルの内容を画面に表示します。該当するファイルがない場合にはエラーになります。
				
			
					
サンプル
					
#!/usr/local/bin/lua
io.input("./sample.txt")
while true do
text = io.read()
if text == nil then break end
print(text)
end
			
			
					
					
Lua Sample text
これはLuaのサンプルです。