Problem Statement: Counting Adjacent Bombs in a Grid with File I/O
You are given a grid stored in a file. Implement a program that reads the grid from input.txt, computes, and writes the result to output.txt.
Rules
The grid has height H and width W, with H strings S_1, S_2, ..., S_H each of length W.
Each character is either '.' (an empty square) or '#' (a square containing a bomb).
For every empty cell '.', replace it with a digit representing the number of adjacent bomb squares. A cell is adjacent if it is horizontally, vertically, or diagonally neighboring (up to eight neighbors).
Each '#' in the input should remain '#' in the output.
Input File (input.txt)
The first line contains two integers H and W.
The next H lines each contain a string of length W consisting of '.' and '#'.
Output File (output.txt)
Write H lines. In each line, replace every '.' with the corresponding digit (0–8) indicating the number of adjacent bombs. Keep all '#' characters unchanged.
Constraints
1 ≤ H, W ≤ 100
Example
Input (input.txt):
3 4
.#..
##..
....
Output (output.txt):
1110
#21.
0000
Implementation Notes
Place your program in the /app/ directory.
The program must read from input.txt and write to output.txt as described above, performing the exact transformation rules.