Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

bookstorerelationship!

# 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
  1. Enter the name of the file you wish to read (e.g., input.txt).
  2. Provide a name for the output file where the modified content will be saved (e.g., output.txt).

Example

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.

Error Handling

  • 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.

Customization

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.

License

This program is free to use and modify. Feel free to share it with others!

Contact

If you encounter any issues or have suggestions for improvement, reach out to us!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages