Ivan had some money. After spending $6 on a file, and 1/3 of his remaining money on a pen, he had 4/9 of the total amount of money left. How much money did Ivan have in the beginning?

amount at start ---- x

x - 6 - (1/3)(x-6) = (4/9)x
times 9 , to clear fractions
9x - 54 - 3(x - 6) = 4x
2x = 36
x = 18 <------ the amount he started with

check:
start with 18, spends 6
amount left = 12
spends 1/3 of that, which is 4
amount left over = 12-4 = 8
and what is (4/9)(18) ? Well, that just happens to be 8
My answer must be correct!

Yes! That is correct. 18 is the answer