# fileRead (Shared)

> Reads bytes from a file at the current position and moves the position on.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Files
- **URL**: https://wiki.mymp.gg/en/fileRead

## Syntax

```lua
string fileRead(file file, int count)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `file` | `file` | A file opened by `fileOpen` or `fileCreate`. |
| `count` | `int` | How many bytes to read, 0 or more. |

## Returns

The bytes read. It may hold fewer than `count` (or be empty) near the end.

## Example

```lua
local file = fileOpen("data.bin", true)
while file and not fileIsEOF(file) do
    local chunk = fileRead(file, 4096)
    print(#chunk)
end
if file then fileClose(file) end
```

## See also

- [fileWrite (Shared)](https://wiki.mymp.gg/en/fileWrite.md): Writes one or more texts to a file, at the current position.
- [fileSetPos (Shared)](https://wiki.mymp.gg/en/fileSetPos.md): Changes a file's read and write position.
- [fileIsEOF (Shared)](https://wiki.mymp.gg/en/fileIsEOF.md): Tells whether a file's position has reached its end.
- [fileGetContents (Shared)](https://wiki.mymp.gg/en/fileGetContents.md): Reads a whole file at once, without opening it.
