# File not found

**URL:** https://discuss.kotlinlang.org/t/file-not-found/19853
**Category:** Support
**Created:** [November 8, 2020, 2:14pm UTC](https://discuss.kotlinlang.org/t/file-not-found/19853 "2020-11-08T14:14:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![geruggimarco](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@geruggimarco](https://discuss.kotlinlang.org/u/geruggimarco)
#### Post date: [November 8, 2020, 2:14pm UTC](https://discuss.kotlinlang.org/t/file-not-found/19853/1 "2020-11-08T14:14:25Z")

</div>

Hi,  
Can you help me find a solution to fix this code?

```
    import java.io.File

    fun main() {
    val res = "./resources"
    val pets = "pets.txt"
    val pFile = File("${res}/$pets")

    val file = File("${res}/text.txt")
    file.forEachLine { println(it) }

    val writeFile = File("$res/write.txt")
    writeFile.writeText("Kotlin = happiness")

    val pList = listOf("cat", "dog", "bird")
    pFile.writeText("")
    pList.forEach{ pFile.appendText("$it\n")}

    val newPets = mutableListOf<String>()
    pFile.forEachLine { newPets.add(it) }
    println()
    println(newPets)

    val exists = pFile.exists()
    println("\npets exists? $exists")
}

```

when I try to compile it appears the following error code:

```
    Exception in thread "main" java.io.FileNotFoundException: ./resources/text.txt (No such file or directory)
    	at java.base/java.io.FileInputStream.open0(Native Method)
    	at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
    	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
    	at kotlin.io.FilesKt__FileReadWriteKt.forEachLine(FileReadWrite.kt:190)
    	at kotlin.io.FilesKt__FileReadWriteKt.forEachLine$default(FileReadWrite.kt:188)
    	at chapter5._05_03.end.Read_and_write_fileKt.main(read_and_write_file.kt:11)
    	at chapter5._05_03.end.Read_and_write_fileKt.main(read_and_write_file.kt)

    Process finished with exit code 1

```

---

<div class="post-metadata">

### Author: ![geruggimarco](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@geruggimarco](https://discuss.kotlinlang.org/u/geruggimarco)
#### Post date: [November 8, 2020, 2:27pm UTC](https://discuss.kotlinlang.org/t/file-not-found/19853/2 "2020-11-08T14:27:22Z")

</div>

Sorted!!!  
the problem was in the “run/debug configuration”, specifically in the "working directory"

 ![Screenshot from 2020-11-08 14-20-24](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/0/0e1b52d7b8afd0c9a7f4be479802f7b40bcf2430.png)
