---
title: "init(toFileAtPath:append:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/outputstream/init(tofileatpath:append:)"
---

# init(toFileAtPath:append:)

Returns an initialized output stream for writing to a specified file.

## Declaration

```swift
convenience init?(toFileAtPath path: String, append shouldAppend: Bool)
```

## Parameters

- `path`: The path to the file the output stream will write to.
- `shouldAppend`: doc://com.apple.documentation/documentation/Swift/true if newly written data should be appended to any existing file contents, otherwise doc://com.apple.documentation/documentation/Swift/false.

## Return Value

Return Value An initialized output stream that can write to path.

## Discussion

Discussion The stream must be opened before it can be used.

## See Also

### Creating Streams

- [toMemory()](foundation/outputstream/tomemory().md)
- [init(toMemory:)](foundation/outputstream/init(tomemory:).md)
- [init(toBuffer:capacity:)](foundation/outputstream/init(tobuffer:capacity:).md)
- [init(url:append:)](foundation/outputstream/init(url:append:)-5soau.md)
