<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/OutputStream/init(toFileAtPath:append:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOutputStream(im)initToFileAtPath:append:"
  },
  "title" : "init(toFileAtPath:append:)"
}
-->

# init(toFileAtPath:append:)

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

```
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

An initialized output stream that can write to `path`.

## Discussion

The stream must be opened before it can be used.

## See Also

[`outputStreamToFileAtPath:append:`](/documentation/Foundation/NSOutputStream/outputStreamToFileAtPath:append:)

Creates and returns an initialized output stream for writing to a specified file.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)