# File Read & Write Program 🖋️
## Overview
This program reads content from a specified file, modifies it by appending line numbers to each line, and writes the modified content to a new file. It also includes robust error handling to gracefully manage common issues like missing files or permission errors.
## Features
- Reads content from a user-specified file.
- Adds line numbers to the content for better readability.
- Saves the modified content to a new file.
- Provides error handling for:
- Missing files (`FileNotFoundError`).
- Read/write permission issues (`IOError`).
- Unexpected errors (`Exception`).
## Usage
### Prerequisites:
- Make sure you have Python 3 installed on your system.
- The input file must exist in the directory where the program is run.
### Steps to Run:
1. Open a terminal or command prompt.
2. Run the Python script:
```bash
python your_script_name.py- Enter the name of the file you wish to read (e.g.,
input.txt). - Provide a name for the output file where the modified content will be saved (e.g.,
output.txt).
Input File (input.txt):
Hello, World!
This is a test file.
File Read & Write Challenge.
After Running the Program:
Output File (output.txt):
1: Hello, World!
2: This is a test file.
3: File Read & Write Challenge.
- If the specified input file does not exist, the program will display:
Error: The file does not exist. Please check the filename and try again. - If the program encounters a read/write issue, it will display:
Error: Unable to read/write file. Ensure you have the correct permissions. - For any unexpected errors, the program provides a friendly message along with the error details.
You can customize the program by modifying:
- The logic for altering content (e.g., adding a timestamp instead of line numbers).
- The error messages for specific scenarios.
This program is free to use and modify. Feel free to share it with others!
If you encounter any issues or have suggestions for improvement, reach out to us!