Implement a function that removes duplicate characters from a given string while preserving the order of first occurrences.
In addition, create a single cohesive program that reads input from a file and writes output to a file.
Functionality:
The function remove_duplicates should take a single string as input and return a new string that contains only the first occurrence of each character from the input string. Any subsequent occurrences of the same character should be omitted.
Input/Output Requirements:
Input: The file /app/input.txt contains a single line with the input string (which may include lowercase and uppercase letters, numbers, spaces, and special characters). The line should be read and the trailing newline removed.
Output: The file /app/output.txt should contain the deduplicated string as a single line.
Implementation Instructions:
Create a Python file named /app/solution.py.
Implement the remove_duplicates function in this file, following the provided function signature:
def remove_duplicates(str):
# Your implementation here
Include a main block that:
Reads the input string from /app/input.txt (UTF-8, first line, trailing newline removed).
Calls remove_duplicates on that string.
Writes the result to /app/output.txt (UTF-8) as a single line.
Ensure the program handles empty input gracefully and preserves the original order of first occurrences.
The program should be ready to run as a script and also importable as a module without executing the I/O portion automatically.
Testing Guidance:
To test, write test strings into /app/input.txt and run the program, then check /app/output.txt for the correct result.