---
title: lines
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/url/lines
---

# lines

The URL’s resource data, as an asynchronous sequence of lines of text.

## Declaration

```swift
var lines: AsyncLineSequence<URL.AsyncBytes> { get }
```

## Discussion

Discussion Use this property with Swift’s for-await-in syntax, to read the contents of a URL line-by-line, like this: guard let url = URL(string: "https://www.example.com") else {     return } do {     // Read each line of the data as it becomes available.     for try await line in url.lines     {         // Do something with line.     } } catch {      print ("Error: \(error)") } To wait for the entire resource to load, use the URLSession method data(from:delegate:) with the await keyword. URLSession also offers methods to upload data to a URL endpoint and download a URL’s contents to a file.

## See Also

### Loading URL contents asynchronously

- [resourceBytes](foundation/url/resourcebytes.md)
- [URL.AsyncBytes](foundation/url/asyncbytes.md)
