Write data to a file.

== Function ==
=== Synopsis ===
<source lang="lua">
success, err = File:write( data, size )
</source>
=== Arguments ===
{{param|string|data|The string data to write.}}
{{param|number|size (all)|How many bytes to write.}}
=== Returns ===
{{param|boolean|success|Whether the operation was successful.}}
{{param|string|err|The error string if an error occurred.}}

== Function ==
=== Synopsis ===
<source lang="lua">
success, err = File:write( data, size )
</source>
=== Arguments ===
{{param|Data|data|The Data object to write.}}
{{param|number|size (all)|How many bytes to write.}}
=== Returns ===
{{param|boolean|success|Whether the operation was successful.}}
{{param|string|errorstr|The error string if an error occurred.}}

== Notes ==
'''Writing to multiple lines''': In Windows, some text editors (e.g. Notepad before Windows 10 1809) only treat CRLF ("\r\n") as a new line.
<source lang="lua">
--example
f = love.filesystem.newFile("note.txt")
f:open("w")
for i = 1, 10 do
    f:write("This is line "..i.."!\r\n")
end
f:close()
</source>

== See Also ==
* [[parent::File]]
* [[(File):flush|File:flush]]
* [[(File):setBuffer|File:setBuffer]]
[[Category:Functions]]
{{#set:Description=Write data to a file.}}
{{#set:Since=000}}
== Other Languages ==
{{i18n|(File):write}}