When a file is both read from and written to in the same pipeline, a race condition occurs where the file may be truncated before it's fully read, resulting in data loss. To avoid this issue, use an intermediate file or process substitution to separate the read and write operations.